Skip to content

馃拝 Consistent crash on malformed ternary聽#1695

Closed

Description

@fmajestic

Environment information

CLI:
  Version:                      1.5.3
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v21.5.0"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         "bun/1.0.25"

Biome Configuration:
  Status:                       Loaded successfully
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 true

Workspace:
  Open Documents:               0

Rule name

lint/correctness/noUnusedVariables

Playground link

https://biomejs.dev/playground/?lintRules=all&code=dAB5AHAAZQAgAFQAbwBQAGEAcwBjAGEAbABDAGEAcwBlADwAUwAgAGUAeAB0AGUAbgBkAHMAIABzAHQAcgBpAG4AZwA%2BACAAPQAgAFMAIABlAHgAdABlAG4AZABzACAAYAAkAHsAaQBuAGYAZQByACAAUAByAGUAZgBpAHgAfQBgACAAPwAgADoAIAA7AA%3D%3D

Expected result

I'm getting this crash message:

Source Location: /home/runner/work/biome/biome/crates/biome_js_semantic/src/semantic_model/model.rs:334:46
Thread Name: main
Message: no entry found for key

Just as the placeholder for this field says, "It should not throw an error." 馃槤

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Activity

  1. ematipico commented on Jan 29, 2024

    @ematipico
    Member

    The code that you pasted is not valid. Look at the playground, and even Prettier throws an error. And TS too

    I'm not sure why we don't throw any diagnostic though, that's weird.

  2. fmajestic commented on Jan 29, 2024

    @fmajestic
    ContributorAuthor

    Yeah, that's why I specifically said malformed ternary :D. const [xyy:?:""\n} = bar; is also invalid code but doesn't cause a hard crash.

    I managed to narrow down the crash to that specific lint rule, but it happened while I was editing a file and typed in an "empty" ternary like that.

  3. ematipico commented on Jan 29, 2024

    @ematipico
    Member

    Yeah, but the issue is not the linter. It's a parser issue :)

  4. added
    S-Help-wantedStatus: you're familiar with the code base and want to help the project
    S-Bug-confirmedStatus: report has been confirmed as a valid bug
    L-JavaScriptLanguage: JavaScript and super languages
    on Jan 29, 2024
  5. togami2864 commented on Jan 30, 2024

    @togami2864
    Contributor

    I'll take a look:)

  6. togami2864 commented on Feb 4, 2024

    @togami2864
    Contributor

    The parser seems to be working fine, but the issue only reproduces in the production environment馃

    Screen.Recording.2024-02-04.at.16.43.37.mov
  7. ah-yu commented on Feb 4, 2024

    @ah-yu
    Contributor

    Hey @togami2864 , I took a look at this issue before and have some observations that I hope will be helpful:

    • This issue only happens when the NoUnusedVariable rule is enabled.
    • This issue disappears when the true branch of the condition type is not empty playground

    I guess you can explore the issue more from here

    // Delay the declaration of parameter types that are inferred.
    // Their scope corresponds to the true branch of the conditional type.
    self.infers
    .push(TsTypeParameterName::unwrap_cast(node.syntax().clone()));

  8. togami2864 commented on Feb 4, 2024

    @togami2864
    Contributor

    @ah-yu Awesome! Thank you!

  9. Conaclos commented on Apr 26, 2024

    @Conaclos
    Member

    @togami2864 Are you still working on it? If not, I could take a look :)

  10. togami2864 commented on Apr 27, 2024

    @togami2864
    Contributor

    How quickly did you fix it 馃帀 Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-ParserArea: parserL-JavaScriptLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bugS-Help-wantedStatus: you're familiar with the code base and want to help the project

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions