moonbitlang / moonbit-docs

The docs of MoonBit programming language
https://docs.moonbitlang.com
Other
1k stars 50 forks source link

confused error message for struct initialize #278

Open HerrCai0907 opened 1 month ago

HerrCai0907 commented 1 month ago

Parser cannot understand incorrect usage between = and : when initializing struct.

The second error message in example miss the possibility of :.

[4021] Error: The value identifier current is unbound.
   │
 8 │   let engine : SfcEngine = { seed, init_circle, current=0 }
   │                                                 ───┬───  
   │                                                    ╰───── The value identifier current is unbound.
───╯
[3002] Error: Parse error, unexpected token `=`, you may expect `,` or `}`.
   │
 8 │   let engine : SfcEngine = { seed, init_circle, current=0 }
   │                                                        ┬  
   │                                                        ╰── Parse error, unexpected token `=`, you may expect `,` or `}`.
───╯
error: failed when building
Yoorkin commented 1 month ago

Thanks for your feedback, we will improve the error message for this case.