|
|
|
@ -94,9 +94,14 @@ impl Executable for FunctionDecl {
|
|
|
|
|
|
|
|
|
|
// Set the name and assign it in the current environment
|
|
|
|
|
val.set_field("name", self.name(), context)?; |
|
|
|
|
context |
|
|
|
|
.realm_mut() |
|
|
|
|
.environment |
|
|
|
|
|
|
|
|
|
let environment = &mut context.realm_mut().environment; |
|
|
|
|
if environment.has_binding(self.name()) { |
|
|
|
|
environment |
|
|
|
|
.set_mutable_binding(self.name(), val, true) |
|
|
|
|
.map_err(|e| e.to_error(context))?; |
|
|
|
|
} else { |
|
|
|
|
environment |
|
|
|
|
.create_mutable_binding(self.name().to_owned(), false, VariableScope::Function) |
|
|
|
|
.map_err(|e| e.to_error(context))?; |
|
|
|
|
|
|
|
|
@ -105,7 +110,7 @@ impl Executable for FunctionDecl {
|
|
|
|
|
.environment |
|
|
|
|
.initialize_binding(self.name(), val) |
|
|
|
|
.map_err(|e| e.to_error(context))?; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
Ok(Value::undefined()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|