-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support malformed char literals, the second #44989
Conversation
@test_parseerror "'\\xff\\xff\\xff\\xff'" "character literal contains multiple characters" # == reinterpret(Char, 0xffffffff) | ||
@test '\uffff' == Char(0xffff) | ||
@test '\U00002014' == Char(0x2014) | ||
@test '\100' == reinterpret(Char, UInt32(0o100) << 24) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just @
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, perhaps this makes it more obvious:
@test '\100' == reinterpret(Char, UInt32(0o100) << 24) | |
@test '\100' == reinterpret(Char, UInt32(0o100) << 24) == '@' |
@test_parseerror "'\\U00002014a'" "character literal contains multiple characters" | ||
@test_parseerror "'\\1000'" "character literal contains multiple characters" | ||
@test Meta.isexpr(Meta.parse("'a"), :incomplete) | ||
@test ''' == "'"[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I never realized that would work, but it already does so carry on...
I think this implements exactly what I had in mind. My only quibble is with the commit message, which says:
That isn't strictly true since it allows invalid UTF-8, so I would describe this perhaps this way:
|
This is pulled out from #44989. Making `test_parseerror` a macro leads to much more helpful stacktraces if something fails.
71683df
to
16e37c2
Compare
Tidied up and added news, should be ready to merge. |
16e37c2
to
a1ce793
Compare
I see this changed the flisp parser, so I guess JuliaSyntax.jl needs to be updated too, I assume forgotten. I'm also thinking, invalid UTF-8 means overlong, and it can be overlong to arbitrary degree (in Strings), while Char is fixed, was that an( unsolvable?) problem thought of? |
Alternative to #44765. This disallows character literals that can not be
created from iterating a UTF-8 string.
fixes #25072