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

zig: Assertion failed when returning a type that "closes over" a local #552

Closed
scurest opened this issue Oct 20, 2017 · 0 comments
Closed

zig: Assertion failed when returning a type that "closes over" a local #552

scurest opened this issue Oct 20, 2017 · 0 comments
Labels
Milestone

Comments

@scurest
Copy link
Contributor

@scurest scurest commented Oct 20, 2017

fn f() -> type {
    const c = 1;
    struct {
        fn g() -> i32 { c }
    }
}

pub fn main() -> %void {
    const x = f().g();
}

fails to compile with the error (line)

zig:
  /home/scurest/zig/src/ir.cpp:7041:
  bool ir_num_lit_fits_in_other_type(IrAnalyze*, IrInstruction*, TypeTableEntry*, bool):
  Assertion `const_val->special != ConstValSpecialRuntime' failed.

Workaround is to move the definition of c into the body of g.

Congrats on 0.1.1 btw :)

@andrewrk andrewrk added the bug label Oct 20, 2017
@andrewrk andrewrk added this to the 0.2.0 milestone Oct 20, 2017
@andrewrk andrewrk closed this in e7c04b6 Jan 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants