Skip to content

Commit

Permalink
If var not in scope yet, add it (it's in the body of a probe
Browse files Browse the repository at this point in the history
  • Loading branch information
ejrgilbert committed May 28, 2024
1 parent 64f9608 commit 115f74a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/generator/emitters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,11 +925,16 @@ impl WasmRewritingEmitter {
let mut addr = if let Expr::VarId { name, .. } = var_id {
let var_rec_id = match self.table.lookup(name) {
Some(rec_id) => rec_id.clone(),
_ => {
None => {
// TODO -- add variables from body into symbol table
// (at this point, the verifier should have run to catch variable initialization without declaration)
return Err(ErrorGen::get_unexpected_error(true, Some(format!("{UNEXPECTED_ERR_MSG} \
VarId '{name}' does not exist in this scope!")), None));
self.table.put(name.clone(), Record::Var {
ty: ty.clone(),
name: name.clone(),
value: None,
addr: None,
loc: None
})
}
};
match self.table.get_record_mut(&var_rec_id) {
Expand Down

0 comments on commit 115f74a

Please sign in to comment.