rust-lang / rust-lang/fls

Processing shebang and byte order mark

Open
#613 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
reStructuredText
Stars
497
Forks
41
Avg merge
3h 52m
Merged PRs (30d)
4

Description

Shebang

§18.1 (fls_s35hob3i7lr) provides the following syntax definitions:

SourceFile ::=
    ZeroWidthNoBreakSpace?
    Shebang?
    InnerAttributeOrDoc*
    Item*

Shebang ::=
    #! ~[NewLine]*

NewLine ::=
    \n

This grammar is ambiguous: a file starting with the following could be treated as starting with either a Shebang or an InnerAttributeOrDoc:

#![xxx]

This is an unusual case where the ambiguity isn't resolved "eagerly": rustc sees this as InnerAttributeOrDoc. So I think the FLS ought to say more here.

Also, I think putting a nonterminal inside ~[] isn't strictly following the notation described by §1.1.4:14 (fls_blvsfqeevosr). The definition of NewLine isn't used anywhere else.

Byte order mark

§18.1:2 (fls_ann3cha1xpek) reads

A Shebang does not have an effect on the compilation.

I suggest adding a similar statement for the ZeroWidthNoBreakSpace.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with §18.1 and compare its SourceFile, Shebang, and NewLine definitions with the notation rules in §1.1.4:14. Check rustc's handling of #![xxx] and the leading zero-width no-break space, then update the relevant FLS text so the grammar and compilation-effect statements match the intended behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.