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

Confusing error message when using is with a constant rvalue #20891

Closed
zeozeozeo opened this issue Feb 22, 2024 · 4 comments · Fixed by #21207
Closed

Confusing error message when using is with a constant rvalue #20891

zeozeozeo opened this issue Feb 22, 2024 · 4 comments · Fixed by #21207
Labels
Unit: Checker Bugs/feature requests, that are related to the type checker. Unit: Compiler Bugs/feature requests, that are related to the V compiler in general.

Comments

@zeozeozeo
Copy link
Contributor

zeozeozeo commented Feb 22, 2024

V doctor:

V full version: V 0.4.4 86c0271.10c2f9e
OS: windows, Microsoft Windows 10 Pro v19045 64-bit
Processor: 20 cpus, 64bit, little endian, 

getwd: C:\Users\user\Desktop\Code\leaflang
vexe: C:\Users\user\Desktop\Code\v\v.exe
vexe mtime: 2024-02-22 21:58:37

vroot: OK, value: C:\Users\user\Desktop\Code\v
VMODULES: OK, value: C:\Users\user\.vmodules
VTMP: OK, value: C:\Users\user\AppData\Local\Temp\v_0

Git version: git version 2.42.0.windows.1
Git vroot status: weekly.2024.07-57-g10c2f9e0
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,

operable program or batch file.


thirdparty/tcc status: thirdparty-windows-amd64 b99a453d

What did you do?
v -g -o vdbg cmd/v && vdbg test.v

module testmod

struct Foo {
	foo int
}
struct Bar {
	bar i8
}

type Foobar = Foo | Bar

const empty_foo = Foo{foo: 0}

fn main() {
	fb := Foobar(Foo{foo: 5})
	empty := testmod.empty_foo // this doesn't produce any error
	if fb is testmod.empty_foo {} // this should be "type `testmod.empty_foo` does not exist"
}

What did you expect to see?

error like "type testmod.empty_foo does not exist"

What did you see instead?

test.v:17:10: error: unknown module `testmod`
   15 |     fb := Foobar(Foo{foo: 5})
   16 |     empty := testmod.empty_foo // this doesn't produce any error
   17 |     if fb is testmod.empty_foo {} // this should be "type `testmod.empty_foo` does not exist"
      |             ~~~~~~~
   18 | }

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.

@JalonSolov
Copy link
Contributor

The error message should be unnecessary module prefix.

@zeozeozeo
Copy link
Contributor Author

The error message should be unnecessary module prefix.

i thought you can't compare the inner sumtype type with a value? ican't test it right now, but shouldn't the right side of is be a type?

@JalonSolov
Copy link
Contributor

My point is that testmod isn't an unknown module. It is the current module. That's why it is unnecessary to put the module name on that line (and the previous one).

@zeozeozeo
Copy link
Contributor Author

My point is that testmod isn't an unknown module. It is the current module. That's why it is unnecessary to put the module name on that line (and the previous one).

vfmt automatically prepends the current module to constants though

@felipensp felipensp added Unit: Compiler Bugs/feature requests, that are related to the V compiler in general. Unit: Checker Bugs/feature requests, that are related to the type checker. labels Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unit: Checker Bugs/feature requests, that are related to the type checker. 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.

3 participants