Skip to content

Commit

Permalink
fix: lower LetStatement assignment, insert Define, improve HashMap error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray Redondo committed Aug 2, 2023
1 parent d6024e4 commit 0a1dfec
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions rust/src/sema/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ impl<'a> HirLowerer<'a> {
var,
ty,
}));
if let Some(x) = &stmt.val {
let val = self.desugar_expr(x)?;
self.stmts.push(stmt.copy_span(|_| HirStatement::Assign {
dest: var.copy_span(|x| HirExpr::Var(*x)),
val,
op: None,
}));
}
}
ast::Statement::Block(blk) => match &blk.body {
ast::CompoundBlock::SimpleBlock(blk) => {
Expand Down
4 changes: 3 additions & 1 deletion rust/src/sema/mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,9 @@ impl<'a> MirConverter<'a> {
let val = self.lower_expr(val)?;
self.lower_write(dest, val, op, span)?;
}
ThirStatement::Define { .. } => {}
ThirStatement::Define { var, .. } => {
self.hir_def_spans.insert(var.body, var.span);
}
ThirStatement::Return(expr) => {
let expr = self.lower_expr(expr)?;

Expand Down
2 changes: 1 addition & 1 deletion xlang/xlang_abi/src/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ where
{
type Output = V;
fn index(&self, idx: &'a Q) -> &V {
self.get(idx).unwrap()
self.get(idx).expect("no entry found for key")
}
}

Expand Down

0 comments on commit 0a1dfec

Please sign in to comment.