rokucommunity / rokucommunity/brighterscript

single-line if statement parsed wrong

Open
#137 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

parser
Dominant language
TypeScript
Stars
208
Forks
68
Avg merge
8h 39m
Merged PRs (30d)
39

Description

This test fails. The aa.value = 8 code turns into its own statement, and the else branch is empty. I don't think this happens in brs, so this is something we introduced in the brighterscript parser.

 it('supports single-line if-else', () => {
        let { tokens } = Lexer.scan(`
            if foo > 5 then aa.value = ">5" else aa.value = 8
        `);
        let { statements, diagnostics } = Parser.parse(tokens);
        expect(diagnostics).to.be.lengthOf(0);
        let statement = statements[0] as IfStatement;
        expect(statement).to.be.instanceof(IfStatement);
        expect(statement.elseBranch).to.exist;
    });

Contributor guide

No contributing guide indexed for this repository

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 the single-line if-else example and trace the tokens from Lexer.scan into Parser.parse. Confirm the parsed result is an IfStatement with an existing elseBranch, no diagnostics, and both assignment statements in their respective branches.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.