Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ“ biom crashed #2243

Closed
1 task done
NyanHelsing opened this issue Mar 30, 2024 · 3 comments Β· Fixed by #2250
Closed
1 task done

πŸ“ biom crashed #2243

NyanHelsing opened this issue Mar 30, 2024 · 3 comments Β· Fixed by #2250
Assignees
Labels
A-Analyzer Area: analyzer L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@NyanHelsing
Copy link

Environment information

❯ pnpm biome check . --apply
Biome encountered an unexpected error

This is a bug in Biome, not an error in your code, and we would appreciate it if you could report it to https://github.com/biomejs/biome/issues/ along with the following information to help us fixing the issue:

Source Location: crates/biome_js_analyze/src/utils.rs:109:13
Thread Name: biome::worker_5
Message: internal error: entered unreachable code: The node can't have the same range of the operator.

Configuration

N/A

Playground link

n/a

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@Sec-ant
Copy link
Contributor

Sec-ant commented Mar 31, 2024

This error is thrown from this function. Would you please help us narrow down the source code file which triggers this error?

/// Finds the position of a variable relative to a binary expression.
///
/// This function takes a reference to a JsBinaryExpression and the name of a variable as input.
/// It determines whether the variable appears to the left or right of the binary operator within
/// the expression and returns the result as an `Option<VariablePosition>`.
///
/// Depending on your specific expression and variable placement,
/// the result may vary between Left, Right, or None.
pub(crate) fn find_variable_position(
binary_expression: &JsBinaryExpression,
variable: &str,
) -> Option<VariablePosition> {
let operator_range = binary_expression
.operator_token()
.ok()?
.text_trimmed_range();
binary_expression
.syntax()
.children()
.filter_map(AnyJsExpression::cast)
.map(|child| child.omit_parentheses())
.filter(|child| child.syntax().text_trimmed() == variable)
.map(|child| {
if child.syntax().text_trimmed_range().end() < operator_range.start() {
return VariablePosition::Left;
} else if operator_range.end() < child.syntax().text_trimmed_range().start() {
return VariablePosition::Right;
}
unreachable!("The node can't have the same range of the operator.")
})
.next()
}

@Sec-ant Sec-ant added L-JavaScript Language: JavaScript and super languages S-Needs response Status: await response from OP A-Analyzer Area: analyzer labels Mar 31, 2024
@NyanHelsing
Copy link
Author

NyanHelsing commented Mar 31, 2024

New information:

This is caused by a minified file
If I format it before linting, the linting works.

The file that Errors:

https://github.com/NyanHelsing/biome/blob/main/main-errors.js

Other Thoughts

Biome might consider an option to ignore hidden files/dirs; (begin with .) and have this enabled by default as a short term solution to preven t folks from encountering this and being very confused.

Overall i'd expect biome to be successful on even large and minified files though; and i'm not really sure exactly what is breaking in this file?

Biome seems to use uint32 which certainly seems to give enough room for any file even this one (which is about a 700kb)

@Sec-ant
Copy link
Contributor

Sec-ant commented Mar 31, 2024

This error has nothing to do with the file size. I managed to narrow down the code that triggers this error:

l-=l-c

This should be a bug of the analyzer.

@Sec-ant Sec-ant added A-Parser Area: parser S-Bug-confirmed Status: report has been confirmed as a valid bug and removed S-Needs response Status: await response from OP A-Parser Area: parser labels Mar 31, 2024
@Sec-ant Sec-ant self-assigned this Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Analyzer Area: analyzer L-JavaScript Language: JavaScript and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants