-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
incorrect search results for malformed Char
#48283
Comments
Using reinterpret is bound to be able to create instances that violate any assumptions, and thus can break code. |
I advocated for allowing those, but it was eventually decided against. This just creates a command literal, if you try this with a character literal this will throw a syntax error: julia> '\x7e\xff\xff\xff'
ERROR: syntax: character literal contains multiple characters
Stacktrace:
[1] top-level scope
@ none:1 See also @StefanKarpinski's comment in #44765 (comment), which might also be relevant here:
|
That's certainly an option. (It doesn't crash, it just gives a surprising result.) It might be nicer to throw an exception, since it shouldn't be too costly in the context of a search routine to check for a malformed |
I noticed in #48281 that various search routines are giving incorrect results because they check for ASCII chars via
c ≤ '\x7f'
rather thanisascii(c)
, which can be wrong for a malformedChar
:These search results seem clearly wrong to me — they are treating
c
as if it were== Char(0x7e) == '~'
.It's not entirely clear to me what the correct behavior should be, however, since Julia never treats
'\x7e\xff\xff\xff'
as a character in a string:"$c" == "~\xff\xff\xff"
. Maybe these routines should throw an error if the character is malformed?cc @StefanKarpinski, who wrote this code in #24999.
See also #44989, where such characters literals were
alloweddisallowed:even thoughsince it is impossible(?) to obtain such aChar
by iterating aString
.The text was updated successfully, but these errors were encountered: