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

Compiler aborts on "global" const function ref #257

Closed
ofelas opened this issue Feb 8, 2017 · 2 comments
Closed

Compiler aborts on "global" const function ref #257

ofelas opened this issue Feb 8, 2017 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@ofelas
Copy link

ofelas commented Feb 8, 2017

Example code; (Is there a name for this?)

const io = @import("std").io;
// (1) Does not work as expected?!
//const cpf = io.stdout.printf;
var vpf = io.stdout.printf;

pub fn main(args: [][] u8) -> %void {
    // (1) Works here
    const cpf = io.stdout.printf;
    %%io.stdout.printf("args.len={}\n", args.len);
    // (1) When cpf in global scope
    // zig: ../src/codegen.cpp:767: LLVMOpaqueValue* ir_llvm_value(CodeGen*, IrInstruction*):
    // Assertion `instruction->value.special != ConstValSpecialRuntime' failed.
    // Aborted
    %%cpf("args.len={}\n", args.len);
    for (args) |*a| {
        %%io.stdout.printf("{}\n", *a);
        %%cpf("{}\n", *a);
        // ./bug001.zig:14:11: error: type '(bound fn(&OutStream,var,var)->var)' not a function
        // %%vpf("{}\n", *a);
    }
}
@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Feb 9, 2017
@andrewrk andrewrk added this to the 0.1.0 milestone Feb 9, 2017
@andrewrk
Copy link
Member

Thanks for this report. I've been working on it all day and it's revealed some deeper problems that I am fixing.

andrewrk added a commit that referenced this issue Feb 11, 2017
@andrewrk
Copy link
Member

cpf at global scope works now. As for vpf, I think that's the same issue as #141.

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