Don't always assume that an assignment statement will result in a constant
If an assignment statement has a list as its RHS, it will not create a constant. We now do a conditional lookup of the last constant index instead. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -707,10 +707,11 @@ impl StmtVisitor for Compiler {
|
|||||||
// TODO - maybe this would be smarter to set up in the AST. I'm 99% sure that the last
|
// TODO - maybe this would be smarter to set up in the AST. I'm 99% sure that the last
|
||||||
// object created, if it were a function object, will be what we're assigning it to, but I
|
// object created, if it were a function object, will be what we're assigning it to, but I
|
||||||
// want to be 100% sure instead of 99%.
|
// want to be 100% sure instead of 99%.
|
||||||
let obj = self.constants.last().unwrap().as_ref();
|
if let Some(obj) = self.constants.last() {
|
||||||
if let Some(fun) = obj.borrow_mut().as_any_mut().downcast_mut::<UserFunction>() {
|
if let Some(fun) = obj.borrow_mut().as_any_mut().downcast_mut::<UserFunction>() {
|
||||||
fun.set_name(Rc::new(name.to_string()));
|
fun.set_name(Rc::new(name.to_string()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user