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

hash_const_val doesn't support bound functions #3699

Closed
daurnimator opened this issue Nov 16, 2019 · 1 comment · Fixed by #4177
Closed

hash_const_val doesn't support bound functions #3699

daurnimator opened this issue Nov 16, 2019 · 1 comment · Fixed by #4177
Labels
bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@daurnimator
Copy link
Collaborator

daurnimator commented Nov 16, 2019

I was experimenting with the following function to get return types of both functions and bound functions:

fn ReturnType(func: var) type {
    return switch(@typeInfo(@typeOf(func))) {
        .Fn => |info| info,
        .BoundFn => |info| info,
        else => @compileError("attempt to get return type of non-function"),
    }.return_type;
}

And I hit:

Unreachable at zig/src/analyze.cpp:5201 in hash_const_val. This is a bug in the Zig compiler.

Traceback:

#4  0x00005555556c4ae1 in hash_const_val (const_val=0x555556be5b38) at /home/daurnimator/src/zig/src/analyze.cpp:5201
#5  0x00005555556c525a in fn_eval_hash (scope=0x555556be5d70) at /home/daurnimator/src/zig/src/analyze.cpp:5384
#6  0x0000555555683d85 in HashMap<Scope*, ConstExprValue*, &(fn_eval_hash(Scope*)), &(fn_eval_eql(Scope*, Scope*))>::key_to_index (this=0x55555581f080, key=@0x7fffffffa248: 0x555556be5d70) at /home/daurnimator/src/zig/src/hash_map.hpp:238
#7  0x0000555555682cc7 in HashMap<Scope*, ConstExprValue*, &(fn_eval_hash(Scope*)), &(fn_eval_eql(Scope*, Scope*))>::internal_get (this=0x55555581f080, key=@0x7fffffffa248: 0x555556be5d70) at /home/daurnimator/src/zig/src/hash_map.hpp:223
#8  0x0000555555682047 in HashMap<Scope*, ConstExprValue*, &(fn_eval_hash(Scope*)), &(fn_eval_eql(Scope*, Scope*))>::maybe_get (this=0x55555581f080, key=@0x7fffffffa248: 0x555556be5d70) at /home/daurnimator/src/zig/src/hash_map.hpp:81
#9  0x000055555564a724 in ir_analyze_fn_call (ira=0x555556bdfcc0, call_instruction=0x555556bdf220, fn_entry=0x555556be0100, fn_type=0x555556be0470, fn_ref=0x555556be0850, first_arg_ptr=0x0, comptime_fn_call=true, fn_inline=FnInlineAuto) at /home/daurnimator/src/zig/src/ir.cpp:16771
#10 0x000055555564c848 in ir_analyze_instruction_call (ira=0x555556bdfcc0, call_instruction=0x555556bdf220) at /home/daurnimator/src/zig/src/ir.cpp:17253
@daurnimator daurnimator added bug Observed behavior contradicts documented or intended behavior stage1 The process of building from source via WebAssembly and the C backend. labels Nov 16, 2019
@andrewrk andrewrk added this to the 0.7.0 milestone Nov 27, 2019
@andrewrk
Copy link
Member

Related: #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 stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants