There is a syntax error in a whitespace?

Today I was doing my daily dose of hacking, in this case, generating Javascript code from C/AL (Don’t ask). I had copy-pasted some Javascript into C/AL, converted it into strings and was met with this error when compiling:

A closer look quickly determined there’s NO syntax error, so what’s wrong?

The red line is kinda wide, and using some shift-cursor keys movement showed that this is one character:

But that is two spaces?

Ahh, mystery bug solved. You can paste TAB characters into C/AL, and they stay as tabs, but the compiler does not like them. Typing a tab gets translated into spaces, but not if you paste it in there, it just looks like 2 spaces but stays as one tab, that cannot be compiled.

Ctrl-H can actually search and replace the tabs with spaces, by copy’pasting the tab into the Find What field:

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.