dusklang / dusk

The Dusk Programming Language
Other
0 stars 0 forks source link

Support aliases to generic structs #128

Closed zachwolfe closed 10 months ago

zachwolfe commented 10 months ago

This should be supported, but currently isn't:

GenericType<|T|> :: struct {
    field: T
}

NonGenericAlias :: GenericType<|i32|>

fn main() {
    non_generic :: NonGenericAlias {
        // We currently get an error here because the compiler doesn't know this field should have the type `i32`
        field: 42
    }
}

Note that the problem here is the alias (hence the name of this issue). That is, if we replace the use of NonGenericAlias in the struct literal with GenericType<|i32|>, this code will work fine.

zachwolfe commented 10 months ago

Fixed in 1b1315d