VarOrName fix in reduced ast
This commit is contained in:
parent
09dbe5b736
commit
29f4060a71
@ -158,7 +158,7 @@ impl Meta<Expression> {
|
|||||||
Value(qualified_name) => {
|
Value(qualified_name) => {
|
||||||
let ref sym_name = match self.fqsn {
|
let ref sym_name = match self.fqsn {
|
||||||
Some(ref fqsn) => fqsn,
|
Some(ref fqsn) => fqsn,
|
||||||
None => return Expr::ReductionError(format!("FQSN lookup for value failed")),
|
None => return Expr::ReductionError(format!("FQSN lookup for value A failed")),
|
||||||
};
|
};
|
||||||
let FullyQualifiedSymbolName(ref v) = sym_name;
|
let FullyQualifiedSymbolName(ref v) = sym_name;
|
||||||
let name = v.last().unwrap().name.clone();
|
let name = v.last().unwrap().name.clone();
|
||||||
@ -196,7 +196,7 @@ fn reduce_lambda(params: &Vec<FormalParam>, body: &Block, symbol_table: &SymbolT
|
|||||||
fn reduce_named_struct(fqsn: Option<&FullyQualifiedSymbolName>, name: &QualifiedName, fields: &Vec<(Rc<String>, Meta<Expression>)>, symbol_table: &SymbolTable) -> Expr {
|
fn reduce_named_struct(fqsn: Option<&FullyQualifiedSymbolName>, name: &QualifiedName, fields: &Vec<(Rc<String>, Meta<Expression>)>, symbol_table: &SymbolTable) -> Expr {
|
||||||
let sym_name = match fqsn {
|
let sym_name = match fqsn {
|
||||||
Some(fqsn) => fqsn,
|
Some(fqsn) => fqsn,
|
||||||
None => return Expr::ReductionError(format!("FQSN lookup for value failed")),
|
None => return Expr::ReductionError(format!("FQSN lookup for value B failed")),
|
||||||
};
|
};
|
||||||
let FullyQualifiedSymbolName(ref v) = sym_name;
|
let FullyQualifiedSymbolName(ref v) = sym_name;
|
||||||
let ref name = v.last().unwrap().name;
|
let ref name = v.last().unwrap().name;
|
||||||
@ -295,9 +295,18 @@ fn handle_symbol(symbol: Option<&Symbol>, inner_patterns: &Vec<Pattern>, symbol_
|
|||||||
_ => panic!("Symbol is not a data constructor - this should've been caught in type-checking"),
|
_ => panic!("Symbol is not a data constructor - this should've been caught in type-checking"),
|
||||||
});
|
});
|
||||||
let bound_vars = inner_patterns.iter().map(|p| match p {
|
let bound_vars = inner_patterns.iter().map(|p| match p {
|
||||||
VarOrName(name) => {
|
VarOrName(meta_name) => {
|
||||||
//if this is a variable, return Some(var.clone()), else None
|
let symbol_exists = meta_name.fqsn.as_ref().and_then(|fqsn| symbol_table.lookup_by_fqsn(&fqsn)).is_some();
|
||||||
unimplemented!()
|
if symbol_exists {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
let QualifiedName(name_elems) = meta_name.node();
|
||||||
|
if name_elems.len() == 1 {
|
||||||
|
Some(name_elems[0].clone())
|
||||||
|
} else {
|
||||||
|
panic!("Bad variable name in pattern");
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
}).collect();
|
}).collect();
|
||||||
|
Loading…
Reference in New Issue
Block a user