Skip to content

Commit fe2ec24

Browse files
authored
fix stack trace (#120)
1 parent e9243b9 commit fe2ec24

File tree

4 files changed

+32
-17
lines changed

4 files changed

+32
-17
lines changed

crates/lean_compiler/src/a_simplify_lang.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,12 +1268,7 @@ fn simplify_lines(
12681268
res.push(SimpleLine::Panic);
12691269
}
12701270
Line::LocationReport { location } => {
1271-
res.push(SimpleLine::LocationReport {
1272-
location: SourceLocation {
1273-
line_number: *location,
1274-
file_id,
1275-
},
1276-
});
1271+
res.push(SimpleLine::LocationReport { location: *location });
12771272
}
12781273
}
12791274
}

crates/lean_compiler/src/lang.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ pub enum Line {
480480
},
481481
// noop, debug purpose only
482482
LocationReport {
483-
location: SourceLineNumber,
483+
location: SourceLocation,
484484
},
485485
CustomHint(CustomHint, Vec<Expression>),
486486
}

crates/lean_compiler/src/parser/parsers/function.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use super::statement::StatementParser;
33
use super::{Parse, ParseContext, next_inner_pair};
44
use crate::{
55
SourceLineNumber,
6-
lang::{AssignmentTarget, Expression, Function, Line, SimpleExpr},
6+
lang::{AssignmentTarget, Expression, Function, Line, SimpleExpr, SourceLocation},
77
parser::{
88
error::{ParseResult, SemanticError},
99
grammar::{ParsePair, Rule},
@@ -71,10 +71,15 @@ impl FunctionParser {
7171
pair: ParsePair<'_>,
7272
ctx: &mut ParseContext,
7373
) -> ParseResult<()> {
74-
let location = pair.line_col().0;
74+
let line_number = pair.line_col().0;
7575
let line = StatementParser.parse(pair, ctx)?;
7676

77-
lines.push(Line::LocationReport { location });
77+
lines.push(Line::LocationReport {
78+
location: SourceLocation {
79+
file_id: ctx.current_file_id,
80+
line_number,
81+
},
82+
});
7883
lines.push(line);
7984

8085
Ok(())

crates/lean_compiler/src/parser/parsers/statement.rs

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use super::{Parse, ParseContext, next_inner_pair};
77
use crate::{
88
SourceLineNumber,
99
ir::HighLevelOperation,
10-
lang::{AssumeBoolean, Condition, Expression, Line},
10+
lang::{AssumeBoolean, Condition, Expression, Line, SourceLocation},
1111
parser::{
1212
error::{ParseResult, SemanticError},
1313
grammar::{ParsePair, Rule},
@@ -158,10 +158,15 @@ impl IfStatementParser {
158158
pair: ParsePair<'_>,
159159
ctx: &mut ParseContext,
160160
) -> ParseResult<()> {
161-
let location = pair.line_col().0;
161+
let line_number = pair.line_col().0;
162162
let line = StatementParser.parse(pair, ctx)?;
163163

164-
lines.push(Line::LocationReport { location });
164+
lines.push(Line::LocationReport {
165+
location: SourceLocation {
166+
file_id: ctx.current_file_id,
167+
line_number,
168+
},
169+
});
165170
lines.push(line);
166171

167172
Ok(())
@@ -260,10 +265,15 @@ impl ForStatementParser {
260265
pair: ParsePair<'_>,
261266
ctx: &mut ParseContext,
262267
) -> ParseResult<()> {
263-
let location = pair.line_col().0;
268+
let line_number = pair.line_col().0;
264269
let line = StatementParser.parse(pair, ctx)?;
265270

266-
lines.push(Line::LocationReport { location });
271+
lines.push(Line::LocationReport {
272+
location: SourceLocation {
273+
file_id: ctx.current_file_id,
274+
line_number,
275+
},
276+
});
267277
lines.push(line);
268278

269279
Ok(())
@@ -307,10 +317,15 @@ impl MatchStatementParser {
307317
pair: ParsePair<'_>,
308318
ctx: &mut ParseContext,
309319
) -> ParseResult<()> {
310-
let location = pair.line_col().0;
320+
let line_number = pair.line_col().0;
311321
let line = StatementParser.parse(pair, ctx)?;
312322

313-
lines.push(Line::LocationReport { location });
323+
lines.push(Line::LocationReport {
324+
location: SourceLocation {
325+
file_id: ctx.current_file_id,
326+
line_number,
327+
},
328+
});
314329
lines.push(line);
315330

316331
Ok(())

0 commit comments

Comments
 (0)