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

type Tree =string | map[string]string confuse v #19811

Closed
xcombelle opened this issue Nov 8, 2023 · 0 comments · Fixed by #19982
Closed

type Tree =string | map[string]string confuse v #19811

xcombelle opened this issue Nov 8, 2023 · 0 comments · Fixed by #19982
Labels
Bug This tag is applied to issues which reports bugs. Build V build error on any OS/CPU architecture. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Type System Bugs/feature requests, that are related to the V types system.

Comments

@xcombelle
Copy link

xcombelle commented Nov 8, 2023

Describe the bug

a c error is produced with the following program

type Tree = string| map[string]string
fn append(mut tree Tree) {
        print(tree["key"])
}

fn main() {
}

Reproduction Steps

xcombelle@iMac xco % cat bug.v
type Tree = string| map[string]string 
fn append(mut tree Tree) {
	print(tree["key"])
}

fn main() {
}

xcombelle@iMac xco % v up       
Updating V...
V is already updated.
Current V version: V 0.4.2 97f7c3f, timestamp: 2023-11-08 20:43:48 +0200
xcombelle@iMac xco % v -cg bug.v
/tmp/v_501/bug.4782279060700994107.tmp.c:12663:27: error: array subscript is not an integer
        print(main__Tree_str(tree[_SLIT("key")]));
                                 ^~~~~~~~~~~~~
1 error generated.
builder error: 
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

xcombelle@iMac xco % 

Expected Behavior

a v compiler error or no error

Current Behavior

a c error is produced

Possible Solution

No response

Additional Information/Context

No response

V version

Current V version: V 0.4.2 97f7c3f

Environment details (OS name and version, etc.)

xcombelle@iMac xco % v doctor
V full version: V 0.4.2 93d5c2d.97f7c3f
OS: macos, macOS, 14.1, 23B74
Processor: 8 cpus, 64bit, little endian, Apple M1

getwd: /Users/xcombelle/xco
vexe: /Users/xcombelle/v/v
vexe mtime: 2023-11-08 19:35:41

vroot: OK, value: /Users/xcombelle/v
VMODULES: OK, value: /Users/xcombelle/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.39.3 (Apple Git-145)
Git vroot status: weekly.2023.44-85-g97f7c3f6
.git/config present: true

CC version: Apple clang version 15.0.0 (clang-1500.0.40.1)
thirdparty/tcc status: thirdparty-macos-arm64 a668e5a0

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.

@xcombelle xcombelle added the Bug This tag is applied to issues which reports bugs. label Nov 8, 2023
@ArtemkaKun ArtemkaKun added Unit: Type System Bugs/feature requests, that are related to the V types system. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Build V build error on any OS/CPU architecture. labels Nov 8, 2023
shove70 added a commit to shove70/v that referenced this issue Nov 24, 2023
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. Build V build error on any OS/CPU architecture. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Type System Bugs/feature requests, that are related to the V types system.
Projects
None yet
2 participants