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

Assertion fail, when using var that could not be inferred in array type. #697

Closed
Hejsil opened this issue Jan 17, 2018 · 0 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@Hejsil
Copy link
Sponsor Contributor

Hejsil commented Jan 17, 2018

Zig version: 0.1.1.92fc5947

var v = 25;

test "" {
    var arr: [v]u8 = undefined;
}
zig: zig/src/ir.cpp:6164: bool ir_num_lit_fits_in_other_type(IrAnalyze*, IrInstruction*, TypeTableEntry*, bool): Assertion `const_val->special != ConstValSpecialRuntime' failed.
zsh: abort (core dumped)  zig test test.zig
  • If we change line 1 to var v : u8 = 25; we get the expected error: unable to evaluate constant expression.
  • Changing line 1 to const v = 25; and our program compiles, as expected.
@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Jan 17, 2018
@andrewrk andrewrk added this to the 0.2.0 milestone Jan 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

2 participants