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

types created inside functions are named after the function #675

Closed
andrewrk opened this issue Jan 7, 2018 · 0 comments
Closed

types created inside functions are named after the function #675

andrewrk opened this issue Jan 7, 2018 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Jan 7, 2018

This is useful for e.g.

pub fn ArrayList(comptime T: type) -> type {
    return struct {
        ...
    };
}

because now the type name created by ArrayList(u8) is ArrayList(u8).

however it becomes more problematic in this case:

export fn entry() {
    const Foo = struct { x: i32 };

    @compileLog(@typeName(Foo));
}

This prints entry() as the name of the Foo type, which is incorrect.

I think inside a function, if you assign an anonymous struct to a variable, we can use the variable name as the type name.

@andrewrk andrewrk added the bug Observed behavior contradicts documented or intended behavior label Jan 7, 2018
@andrewrk andrewrk added this to the 0.2.0 milestone Jan 7, 2018
@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Jan 18, 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

1 participant