You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
❯ cat 3.v
module main
import a
struct DummyStruct {
dummy_item i32
}
__global (
d [a.num_elements]DummyStruct
)
fn main() {}
a.v:
❯ cat a/a.v
module a
pub const num_elements = 10
Compiler invocation and error:
❯ v -enable-globals 3.v
==================
/tmp/v_501/3.01J1JS3A76SW7J937SDV473XT9.tmp.c:2067:2: error: unknown type name 'Array_fixed_main__DummyStruct_0'
Array_fixed_main__DummyStruct_0 d = {0}; // global4
^
1 error generated.
...
==================
(Use `v -cg` to print the entire error message)
builder error:
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .
If const num_elements = 10 is in the main module then the compilation succeeds.
Reproduction Steps
See above.
Expected Behavior
Either the fact that it is invalid to use non-module-local const variables as array dimensions should be documented as such with a suitably information compiler error, or this should be supported and documented.
Current Behavior
See above.
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.6 23e3894
Environment details (OS name and version, etc.)
❯ neofetch --off
spinlock@deadlock.local
-------------------
OS: macOS 14.5 23F79 arm64
Host: Mac14,9
Kernel: 23.5.0
Uptime: 11 days, 12 hours, 1 min
Packages: 250 (port)
Shell: fish 3.7.1
Resolution: 5120x1440 , 3024x1964
DE: Aqua
WM: Quartz Compositor
WM Theme: Blue (Dark)
Terminal: tmux
CPU: Apple M2 Pro
GPU: Apple M2 Pro
Memory: 4667MiB / 32768MiB
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.
The text was updated successfully, but these errors were encountered:
Describe the bug
Consider the following:
3.v:
a.v:
Compiler invocation and error:
If
const num_elements = 10
is in the main module then the compilation succeeds.Reproduction Steps
See above.
Expected Behavior
Either the fact that it is invalid to use non-module-local const variables as array dimensions should be documented as such with a suitably information compiler error, or this should be supported and documented.
Current Behavior
See above.
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.4.6 23e3894
Environment details (OS name and version, etc.)
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.
The text was updated successfully, but these errors were encountered: