diff --git a/crates/lean_compiler/src/a_simplify_lang.rs b/crates/lean_compiler/src/a_simplify_lang.rs index 6466e83a..bb194fe2 100644 --- a/crates/lean_compiler/src/a_simplify_lang.rs +++ b/crates/lean_compiler/src/a_simplify_lang.rs @@ -1268,12 +1268,7 @@ fn simplify_lines( res.push(SimpleLine::Panic); } Line::LocationReport { location } => { - res.push(SimpleLine::LocationReport { - location: SourceLocation { - line_number: *location, - file_id, - }, - }); + res.push(SimpleLine::LocationReport { location: *location }); } } } diff --git a/crates/lean_compiler/src/lang.rs b/crates/lean_compiler/src/lang.rs index 53af6669..47d96fab 100644 --- a/crates/lean_compiler/src/lang.rs +++ b/crates/lean_compiler/src/lang.rs @@ -480,7 +480,7 @@ pub enum Line { }, // noop, debug purpose only LocationReport { - location: SourceLineNumber, + location: SourceLocation, }, CustomHint(CustomHint, Vec), } diff --git a/crates/lean_compiler/src/parser/parsers/function.rs b/crates/lean_compiler/src/parser/parsers/function.rs index d6a09859..efda8db0 100644 --- a/crates/lean_compiler/src/parser/parsers/function.rs +++ b/crates/lean_compiler/src/parser/parsers/function.rs @@ -3,7 +3,7 @@ use super::statement::StatementParser; use super::{Parse, ParseContext, next_inner_pair}; use crate::{ SourceLineNumber, - lang::{AssignmentTarget, Expression, Function, Line, SimpleExpr}, + lang::{AssignmentTarget, Expression, Function, Line, SimpleExpr, SourceLocation}, parser::{ error::{ParseResult, SemanticError}, grammar::{ParsePair, Rule}, @@ -71,10 +71,15 @@ impl FunctionParser { pair: ParsePair<'_>, ctx: &mut ParseContext, ) -> ParseResult<()> { - let location = pair.line_col().0; + let line_number = pair.line_col().0; let line = StatementParser.parse(pair, ctx)?; - lines.push(Line::LocationReport { location }); + lines.push(Line::LocationReport { + location: SourceLocation { + file_id: ctx.current_file_id, + line_number, + }, + }); lines.push(line); Ok(()) diff --git a/crates/lean_compiler/src/parser/parsers/statement.rs b/crates/lean_compiler/src/parser/parsers/statement.rs index 3a698c21..62738a00 100644 --- a/crates/lean_compiler/src/parser/parsers/statement.rs +++ b/crates/lean_compiler/src/parser/parsers/statement.rs @@ -7,7 +7,7 @@ use super::{Parse, ParseContext, next_inner_pair}; use crate::{ SourceLineNumber, ir::HighLevelOperation, - lang::{AssumeBoolean, Condition, Expression, Line}, + lang::{AssumeBoolean, Condition, Expression, Line, SourceLocation}, parser::{ error::{ParseResult, SemanticError}, grammar::{ParsePair, Rule}, @@ -158,10 +158,15 @@ impl IfStatementParser { pair: ParsePair<'_>, ctx: &mut ParseContext, ) -> ParseResult<()> { - let location = pair.line_col().0; + let line_number = pair.line_col().0; let line = StatementParser.parse(pair, ctx)?; - lines.push(Line::LocationReport { location }); + lines.push(Line::LocationReport { + location: SourceLocation { + file_id: ctx.current_file_id, + line_number, + }, + }); lines.push(line); Ok(()) @@ -260,10 +265,15 @@ impl ForStatementParser { pair: ParsePair<'_>, ctx: &mut ParseContext, ) -> ParseResult<()> { - let location = pair.line_col().0; + let line_number = pair.line_col().0; let line = StatementParser.parse(pair, ctx)?; - lines.push(Line::LocationReport { location }); + lines.push(Line::LocationReport { + location: SourceLocation { + file_id: ctx.current_file_id, + line_number, + }, + }); lines.push(line); Ok(()) @@ -307,10 +317,15 @@ impl MatchStatementParser { pair: ParsePair<'_>, ctx: &mut ParseContext, ) -> ParseResult<()> { - let location = pair.line_col().0; + let line_number = pair.line_col().0; let line = StatementParser.parse(pair, ctx)?; - lines.push(Line::LocationReport { location }); + lines.push(Line::LocationReport { + location: SourceLocation { + file_id: ctx.current_file_id, + line_number, + }, + }); lines.push(line); Ok(())