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
The problem is that the code is being interpreted like this: let struct_instance = (MyStruct < int) > { my_field, ie. parsing MyStruct, int, and my_field as expression names, and the : is a parse error while try to parse a { expr } expression.
structMyStruct<T>{my_field:T}fnmain(){let x = MyStruct<i32> { my_field:42};}
<anon>:3:21: 3:26 error: chained comparison operators require parentheses
<anon>:3 let x = MyStruct<i32> { my_field: 42 };
^~~~~
<anon>:3:26: 3:26 help: use `::<...>` instead of `<...>` if you meant to specify type arguments
<anon>:3:37: 3:38 error: expected one of `!`, `.`, `::`, `;`, `{`, `}`, or an operator, found `:`
<anon>:3 let x = MyStruct<i32> { my_field: 42 };
^
I believe current error message for this is quite good-looking, so I think it's safe to say this issue has been fixed.
If a type parametrized struct is constructed with the parameter in the type name, the error produced is not relevant to the actual problem:
followed by:
Will produce the error:
Which does not indicate that the error is due to the inclusion of '
<int>
' after the struct's name.The text was updated successfully, but these errors were encountered: