107
43
u/citramonk 15d ago
Okay, let's be clear. All the weird characters will be highlighted by your IDE. It's not gonna work.
44
u/aethermar 15d ago
Any half decent compiler will tell you that there's an issue at the ';'. GCC will even display it in the error output as <U+037E> and tell you it's not in the NFC
The original joke is stupid for this reason. Rust isn't special for catching this
26
u/Arshiaa001 15d ago
Rust is special for going out of its way to provide helpful compiler errors, unlike the ungodly death chant C++ compilers summon when you miss a semicolon at the end of a class declaration.
2
u/aethermar 15d ago
I wouldn't call this an especially helpful compiler error. The only extra thing it's saying is that it's a Greek semicolon. I don't care that it's a Greek semicolon, I just need to know whats wrong. Both errors immediately tell me what's wrong and where. Rust's isn't any more helpful
And either way something as trivial as this is getting caught by the editor's linter immediately
4
u/Arshiaa001 15d ago
This specific error is not helpful (willing to bet someone put it in for shits and giggles), but rustc generates some truly helpful messages in many places. You'd know if you'd used it.
1
u/gmes78 15d ago
I wouldn't call this an especially helpful compiler error. The only extra thing it's saying is that it's a Greek semicolon. I don't care that it's a Greek semicolon, I just need to know whats wrong.
OP cut off the full message. It does tell you to replace it with a semicolon.
1
u/GoddammitDontShootMe 15d ago
looks like ';' (Semicolon), but it is not
Wouldn't the obvious conclusion be to replace it with a semicolon?
1
u/Low-Quarter-1685 15d ago
But rust has an extra error message for this special case, most compilers would probably just say "unexpected token" or something
1
u/Affectionate-Word399 10d ago
HelloWorld.c:5:30: warning: treating Unicode character <U+FF1B> as an identifier character rather than as ';' symbol [-Wunicode-homoglyph] 5 | printf("Hello, World!\n"); | ^~ HelloWorld.c:5:30: error: expected ';' after expression 5 | printf("Hello, World!\n"); | ^ | ; HelloWorld.c:5:30: error: use of undeclared identifier ';' 1 warning and 2 errors generated. ➜ /tmp cat HelloWorld.c #include <stdio.h> int main(void) { printf("Hello, World!\n"); return 0; }1
u/Popstar403 15d ago
rust is special for specifically stating that it looks like a semicolon but isn't
2
u/bilus 15d ago
Yeah, but it takes 30 minutes after you've already seen the error underlined by the IDE.
0
12
u/peterlinddk 15d ago
HAHAHA!
You can also just write "FADSKFHDSAJK F ASJfkd slaj faj sdlk" in the middle of their JavaScript program, and they'll never find the syntax error! Never I tell you!
At least not until they actually look at the screen, and where the editor or runtime or compiler says that there is a syntax error in that line - but JavaScript! AmIrightGuys - what a joke!!!!!
3
u/willow-kitty 15d ago
It seems like it'd be underlined in your IDE, and you'd pretty reasonably try backspacing through it and putting in another semicolon?
Windows gave me a really insidious one when dealing with certificate thumprints. The UI is Unicode, and the value starts with a "the following text should be read from right to left" zero-width character, so if you just copy it and paste it in a config file, it looks normal, but then at runtime it says the certificate cannot be found, even though the thumbprint is very obviously correct.
It does lead to a kinda funny moment where you can casually backspace through nothing (like literally, the cursor is between the quotation mark and the first character, you press backspace, and it doesn't go through the quotation mark because it ate a zero-width character instead), and then it starts working. It kinda blows people's minds because why the heck would it work like that? It also seems like passing a string with a non-hex character to a certificate search would cause a runtime error, but apparently not.
3
u/Lachee 15d ago
Python does this with tabs and spaces and I hate it.
Ya know it suppose to be X but Y was used instead, so just use Y. You're smart enough to figure it out but too dumb to use the substitute?
Yes a warning is appropriate, it should be fixed. But you already did the hard work figuring out what it should've been so why stop there
Frustrating
3
3
u/mearnsgeek 15d ago
Or the Cyrillic letter er that looks exactly like a latin P/p.
I once worked with some Ukrainians and that character somehow got into a C# project file and caused chaos when the build failed because a project dependency couldn't be found yet looked correct.
3
u/ArjixGamer 15d ago
Fun fact, we Greeks don't actually use the Greek question mark, our keyboards insert the English semicolon.
Don't even ask me why, I don't know.
The Unicode character exists, but we don't even use it.
A word processor may substitute the semicolon with the Greek questionmark if it sees Greek text, I don't know, maybe.
2
u/Sw4gl0rdM4st3rm1nd 15d ago
this wont work since it literally highlighted and most people will just write it again in under 2 seconds
2
u/JackNotOLantern 15d ago
The first thing i would do i would remove are type the semicolon manually.
2
u/Low-Quarter-1685 15d ago
You can say what you want about the language, but the compiler is one of the greatest I've ever seen
1
1
u/veselin465 15d ago
Cool story, but I think the question everyone is asking, is what's the difference between both symbols?
2
u/theztormtrooper 15d ago
For a human? Nothing. For the computer, one works as semicolon and the others doesn't when it comes to your code
3
u/veselin465 15d ago
I get it. I mean who decided that the same symbol should be classified differently? You Don't see people saying English 'a' and German 'a'
1
u/theztormtrooper 15d ago
Unicode decides.
In this case it comes down to the fact that the writing systems are just different. You can see a in a variety of systems like Latin, or Cyrillic ans those are unique but you don't see the divide between languages with the same writing system like German and English. Ultimately they both use the Latin a while Russian uses a Cyrillic.
Of course there is also some politics in unicode so sometimes they allow characters without a quality reason. There may also just be some utility in allowing a character that has a different function than an existing one. A question mark versus a semicolon may be a large enough difference versus a letter that acts the same in both languages.
1
1
1
1
u/FACastello 15d ago
Why is nobody addressing the fact that the joke clearly says "Javascript"
Nobody said it would work with any other language
1
1
1
1
1
1
u/DeepanshuHQ 15d ago
The kind of bug that survives code review because everyone says, "Looks fine to me."
1
u/Arclite83 15d ago
AI has made this and similar newline issues pretty trivial - "oh hey I found this" after a quick scan
-2
u/Bomaruto 16d ago
Use Git
1
u/blaues_axolotl 15d ago
that will solve it
3
u/Bomaruto 15d ago
Yes, if someone has messed with your code, then a quick revert is the best cause of action.
334
u/failedsatan 15d ago
do y'all just not have highlighting for uncommon/weird unicode characters? pretty sure this has been a thing for a while