Skip to content

ShebangDirective should be unconditionally parsed #78054

@333fred

Description

@333fred

Right now, if the #! is not at the very first character of a file, it will not be parsed as a shebang directive:

if (contextualKind == SyntaxKind.ExclamationToken && hashPosition == 0 && !hash.HasTrailingTrivia)
{
result = this.ParseShebangDirective(hash, this.EatToken(SyntaxKind.ExclamationToken), isActive);
}
. This is not good error recovery and will likely make it more difficult for consumers to have analyzers/fixers for this syntax when it is misplaced. We should instead report an error and always parse as a shebang.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions