Shebang error parsing: compatibility with tsc#153
Shebang error parsing: compatibility with tsc#153sandersn merged 6 commits intomicrosoft:mainfrom sandersn:shebang-error-parse-bug-compatibility
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.