Start isolating names into their own thing.
This commit is contained in:
@@ -141,9 +141,9 @@ impl Expression {
|
||||
|
||||
(errors, warnings)
|
||||
}
|
||||
Expression::Reference(_, var) if variable_map.contains_key(var) => (vec![], vec![]),
|
||||
Expression::Reference(loc, var) => (
|
||||
vec![Error::UnboundVariable(loc.clone(), var.clone())],
|
||||
Expression::Reference(var) if variable_map.contains_key(&var.original_name().to_string()) => (vec![], vec![]),
|
||||
Expression::Reference(var) => (
|
||||
vec![Error::UnboundVariable(var.location().clone(), var.original_name().to_string())],
|
||||
vec![],
|
||||
),
|
||||
Expression::FieldRef(_, exp, _) => exp.validate(variable_map),
|
||||
@@ -187,7 +187,7 @@ impl Expression {
|
||||
// immediately check the expression, and go from there.
|
||||
let (errors, mut warnings) = val.validate(variable_map);
|
||||
|
||||
if let Some(original_binding_site) = variable_map.get(&var.name) {
|
||||
if let Some(original_binding_site) = variable_map.get(&var.original_name().to_string()) {
|
||||
warnings.push(Warning::ShadowedVariable(
|
||||
original_binding_site.clone(),
|
||||
loc.clone(),
|
||||
@@ -201,11 +201,11 @@ impl Expression {
|
||||
}
|
||||
Expression::Function(_, name, arguments, _, body) => {
|
||||
if let Some(name) = name {
|
||||
variable_map.insert(name.name.clone(), name.location.clone());
|
||||
variable_map.insert(name.original_name().to_string(), name.location().clone());
|
||||
}
|
||||
variable_map.new_scope();
|
||||
for (arg, _) in arguments.iter() {
|
||||
variable_map.insert(arg.name.clone(), arg.location.clone());
|
||||
variable_map.insert(arg.original_name().to_string(), arg.location().clone());
|
||||
}
|
||||
let result = body.validate(variable_map);
|
||||
variable_map.release_scope();
|
||||
|
||||
Reference in New Issue
Block a user