google / xls

XLS: Accelerated HW Synthesis
http://google.github.io/xls/
Apache License 2.0
1.21k stars 179 forks source link

[DSLX:TS] Give an error if there is an ellipsis without a type annotation. #1689

Closed cdleary closed 2 weeks ago

cdleary commented 3 weeks ago

Previously we would assume we do not need to extend beyond the provided (literal) element count, which led to errors when users did:

fn f() -> u32[4] {
    let x: u32[4] = [u32:42, ...];  // RHS is actually 1 element here, the u32[4] from the type annotation does /not/ propagate into the array expression as context!
}

This also relates to our recent unifying type inference discussions -- in unifying TI we'd make the right hand side type "at least a u32[1] if not more" and then it would unify with u32[4] to say "ok it's a u32[4] filled with the value 42". cc @richmckeever @meheff