-
Notifications
You must be signed in to change notification settings - Fork 655
Shebang error parsing: compatibility with tsc #153
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
Shebang error parsing: compatibility with tsc #153
Conversation
In tsc, `#!` anywhere except pos=0 in a file gives an error and increments past `#`. In tsgo, it was incrementing past `#!`. tsc's behaviour seems bad, but not bad enough to differ from, especially since the parse tree will be wrong either way.
The original code was: case CharacterCodes.hash:
if (pos !== 0 && text[pos + 1] === "!") {
error(Diagnostics.can_only_be_used_at_the_start_of_a_file, pos, 2);
pos++;
return token = SyntaxKind.Unknown;
} What is all of that logic above the code you're modifying? |
The original code checked for valid (This is speculation, maybe @ahejlsberg had some other reason for inlining it.) |
It never made sense to check specifically at the beginning of the function if you want to give a good error message anyway. I did the same thing at microsoft/TypeScript#59244 |
Is it just me or does that inlined code not work for a shebang terminated by any newline character other than |
Shebang only works in Unix doncha know 🙃 |
In tsc,
#!
anywhere except pos=0 in a file gives an error and increments past#
. In tsgo, it was incrementing past#!
. tsc's behaviour seems bad, but not bad enough to differ from, especially since the parse tree will be wrong either way.