You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently types like i32, f32, and str are a separate syntactic class,
which means that code like struct i32 {} produces confusing errors:
error: parse error: Unrecognized token `i32` found at 7:10
Expected one of r#"([A-Za-z]|_)([A-Za-z0-9]|_)*"#
I can't think of a reason off the top of my head why primitives have to be
special-cased in the parser rather than just being declared in libstd.chalk
(or even the IR or something). If there's a reason, I'm curious to here it!
This is probably low-priority, but it might be nice to change.
They can't be declared in libstd.chalk because i32 is not the same as struct i32 {}, from chalks point of view.
As for declaring them in IR, I don't see any benefit in trying to reparse type names to figure out if they are in fact a primitive type when performing AST lowering. It would just transfer the complexity from the parser to lowering.
Currently types like
i32
,f32
, andstr
are a separate syntactic class,which means that code like
struct i32 {}
produces confusing errors:I can't think of a reason off the top of my head why primitives have to be
special-cased in the parser rather than just being declared in
libstd.chalk
(or even the IR or something). If there's a reason, I'm curious to here it!
This is probably low-priority, but it might be nice to change.
See the Zulip discussion.
The text was updated successfully, but these errors were encountered: