{"record":{"id":"f42c5db0becd84a6","repo":"swc-project/swc","slug":"tried-to-parse-the-condition-for-an-if-statement-f42c5d","errorCode":null,"errorMessage":"Tried to parse the condition for an if statement","messagePattern":"Tried to parse the condition for an if statement","errorType":"exception","errorClass":"swc_ecma_parser::error::Error","httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_parser/src/parser/stmt.rs","lineNumber":647,"sourceCode":"            debug_assert_eq!(cur.alt, None);\n            cur.alt = Some(alt);\n        }\n    }\n\n    fn parse_if_stmt(&mut self) -> PResult<IfStmt> {\n        let start = self.cur_pos();\n\n        self.assert_and_bump(Token::If);\n        let if_token = self.input().prev_span();\n\n        expect!(self, Token::LParen);\n\n        let test = self\n            .do_outside_of_context(Context::IgnoreElseClause, |p| {\n                p.allow_in_expr(|p| p.parse_expr())\n            })\n            .map_err(|err| {\n                Error::new(\n                    err.span(),\n                    SyntaxError::WithLabel {\n                        inner: Box::new(err),\n                        span: if_token,\n                        note: \"Tried to parse the condition for an if statement\",\n                    },\n                )\n            })?;\n\n        expect!(self, Token::RParen);\n\n        let cons = {\n            // Prevent stack overflow\n            crate::maybe_grow(256 * 1024, 1024 * 1024, || {\n                // // Annex B\n                // if !self.ctx().contains(Context::Strict) && self.input().is(Token::FUNCTION)\n                // {     // TODO: report error?\n                // }","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_parser/src/parser/stmt.rs#L629-L665","documentation":"Diagnostic label applied by parse_if_stmt: the expression between 'if (' and ')' failed to parse; the original error is nested in SyntaxError::WithLabel with this message so the if-condition is identified as the failing region. The inner boxed error holds the true cause.","triggerScenarios":"Thrown at crates/swc_ecma_parser/src/parser/stmt.rs:647 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read the inner error to find the precise syntax fault","Rewrite or complete the condition expression"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}