dlang-tour / core

D Language online tour (https://tour.dlang.org/) and online editor (https://run.dlang.io/)
Boost Software License 1.0
120 stars 48 forks source link

Exceeding a certain size of code causes misleading compiler errors, e.g. "not allowed in identifier" and "not a valid token" #730

Open thinkingerrol opened 5 years ago

thinkingerrol commented 5 years ago

Take this benign code as an example: https://run.dlang.io/gist/286241cd20de0dd1d634d46e1a6da1c3?args=-Xi%3DcompilerInfo

I'm getting the following errors, some of them even mentioning symbols such as "cannot" which are not in my code:

onlineapp.d(1): Error: char 0x0090 not allowed in identifier
onlineapp.d(1): Error: character 0x90 is not a valid token
onlineapp.d(1): Error: character 0x03 is not a valid token
onlineapp.d(1): Error: character 0x04 is not a valid token
onlineapp.d(1): Error: character 0xb8 is not a valid token
onlineapp.d(1): Error: semicolon expected, not @
onlineapp.d(1): Error: character 0x20ac is not a valid token
onlineapp.d(1): Error: character 0x0e is not a valid token
onlineapp.d(1): Error: character 0x1f is not a valid token
onlineapp.d(1): Error: character 0x0e is not a valid token
onlineapp.d(1): Error: character 0xb4 is not a valid token
onlineapp.d(1): Error: character 0xb8 is not a valid token
onlineapp.d(1): Error: character 0x01 is not a valid token
onlineapp.d(1): Error: multiple ! arguments are not allowed
onlineapp.d(1): Error: semicolon expected, not cannot
onlineapp.d(1): Error: semicolon expected, not run
onlineapp.d(1): Error: no identifier for declarator run
onlineapp.d(1): Error: declaration expected, not in
onlineapp.d(3): Error: character 0x01 is not a valid token
onlineapp.d(3): Error: character 0x03 is not a valid token

These errors disappear if I remove a single byte from the source code, be it from a comment or the unnecessary space before the semicolon in the body of main. They also disappear if I remove the "-Xi=compilerInfo" argument, but even with no arguments reappear again after adding a number of bytes to the source code.

I have to say I've just been experimenting with the multiple-files (HAR) feature and have a feeling I might have thereby caused some kind of unwanted state buildup.