typst
typst copied to clipboard
More helpful error message on `text*//`
Description
No reason to fail there since we accept text//
Reproduction URL
No response
Operating system
No response
Typst version
- [X] I am using the latest version of Typst
I believe the reason for this is that commenting something out never fail due to spurious */.
So, for instance you have a document:
"Hello W*/rld," says Karl the robot.
You can't really comment it out easily:
/*"Hello W*/rld," says Karl the robot.*/
Oh great remark! If that's indeed the problem we could be a bit more explicit in the error message :thinking:
@frozolotl is on point here with the reasoning. if the message is too vague, we can add a hint.
I was thinking of adding the word ambiguous in the error but ambiguous end of comment is a bit long and not that clear
The error message I get is error: unexpected end of block comment, which I think is clear. More ideas are unopened block comment closure/end or ambiguous block comment closure/end.
@laurmaedje Is the hint different than the message printed in the console?
@laurmaedje Is the hint different than the message printed in the console?
Could you clarify what you mean?
I wasn't sure about the mechanics of hints, but I've learned hints are inserted into an error message. We could insert the hints add \* to open the block comment and/or add space after * to avoid ambiguity or similar.
The first one sounds fine. Regarding the second, it might be a better suggestion to escape the * since otherwise there'll (a) be a space, (b) the lone asterisk will be interpreted as syntax for strongly emphasized text.
After poking around, it looks like the error member of the Lexer structure does not support adding hints , like SyntaxError. My initial idea is to use SyntaxError in the Lexer structure, but I am not sure if an easier solution exists (aside from putting the hints as newlines in the error message). I am still new to the whole architecture of this so I will think about it and learn more :)
If switching the Lexer to SyntaxError doesn't cause any problems, it should be fine.