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 crash when generated struct includes field of generated type from fn containing undeclared identifier #1483

Closed
tgschultz opened this Issue Sep 7, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@tgschultz
Contributor

tgschultz commented Sep 7, 2018

const std = @import("std");
const math = std.math;

pub fn Gen(comptime val: u32) type
{
    const UType = @IntType(false, math.ceil(val));

    const S = struct
    {
        code_len: UType,
    };
    return S;
}

test "Crash"
{
    const G = Gen(8);
}

I haven't been able to minimize the circumstances further than the above. As you can see, math.ceil is passed an incorrect type and should produce an error message communicating that. For some reason, this specific construction instead causes a compiler crash.

@andrewrk andrewrk added this to the 0.3.0 milestone Sep 7, 2018

@andrewrk andrewrk added the bug label Sep 7, 2018

@tgschultz tgschultz changed the title from Compiler crash with @IntType under specific circumstances to Compiler crash when generated struct includes field of generated type from fn containing undeclared identifier Sep 7, 2018

@tgschultz

This comment has been minimized.

Contributor

tgschultz commented Sep 7, 2018

A more minimal example:

fn Undeclared() type
{
    return T;
}

fn Gen() type
{
    const X = Undeclared();
    return struct
    {
        x: X,
    };
}

test "undeclared identifier"
{
    const S = Gen();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment