Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgen error: '__v_error' undeclared #21875

Closed
Coachonko opened this issue Jul 15, 2024 · 1 comment · Fixed by #21899
Closed

cgen error: '__v_error' undeclared #21875

Coachonko opened this issue Jul 15, 2024 · 1 comment · Fixed by #21899
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@Coachonko
Copy link
Contributor

Coachonko commented Jul 15, 2024

Describe the bug

module main

import os
import io
import coachonko.luuid

fn prepare_response(s string) []u8 {
	return '${s}\n'.bytes()
}

// commands end with `\n`
fn main() {
	mut generator := luuid.new_generator()
	stdin := os.stdin()
	mut b_reader := io.new_buffered_reader(reader: stdin)
	mut stdout := os.stdout()
	// TODO this sort of loop kills the processor, another ipc technique must be utilized instead.
	for {
		line := b_reader.read_line() or {
			dump(error)
			break
		} // TODO exit loop when eof and pipe closed. should only be when pipe closed.
		println(line)
		if line == 'v1' {
			id := generator.v1() or { 'error' } // TODO handle error
			res := prepare_response(id)
			_ := stdout.write(res) or { 0 } // TODO when could it fail?
		}
	}
}

Reproduction Steps

Accidentally wrote dump(error) instead of dump(err) and got the cgen error when compiling the program.

Expected Behavior

Compiler should tell me error is undeclared instead of producing bad c code

Current Behavior

bad c code

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.6 aa34047, timestamp: 2024-07-15 15:18:49 +0300

Environment details (OS name and version, etc.)

V full version: V 0.4.6 c2f7afd.aa34047
OS: linux, Linux version 5.14.0-427.24.1.el9_4.x86_64 (mockbuild@pp-el9) (gcc (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3), GNU ld version 2.35.2-43.el9) #1 SMP PREEMPT_DYNAMIC Tue Jul 9 00:30:23 CEST 2024
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz

getwd: /home/coachonko/Documents/projects/frontend/wareme/packages/luuid
vexe: /home/coachonko/.local/lib64/v/v
vexe mtime: 2024-07-15 16:55:58

vroot: OK, value: /home/coachonko/.local/lib64/v
VMODULES: OK, value: /home/coachonko/.vmodules
VTMP: OK, value: /tmp/v_1000

Git version: git version 2.43.5
Git vroot status: weekly.2023.45.1-1519-gaa340472
.git/config present: true

CC version: cc (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3)
thirdparty/tcc status: thirdparty-linux-amd64 a0799a5b

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@Coachonko Coachonko added the Bug This tag is applied to issues which reports bugs. label Jul 15, 2024
@felipensp
Copy link
Member

felipensp commented Jul 18, 2024

Simple way to reproduce it:

fn main() {
	dump(error)
}

@felipensp felipensp added the Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. label Jul 18, 2024
@felipensp felipensp self-assigned this Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants