Fixed some code in scope resolver
This commit is contained in:
parent
ddea470ba8
commit
3cf3fce72d
@ -112,7 +112,14 @@ impl<'a> ScopeResolver<'a> {
|
||||
self.invoc(arg)?;
|
||||
}
|
||||
},
|
||||
Lambda { params, body, .. } => {
|
||||
IfExpression { discriminator, body } => {
|
||||
match discriminator {
|
||||
None => (),
|
||||
Some(ref expr) => self.expr(expr)?
|
||||
};
|
||||
self.if_expr_body(body)?;
|
||||
},
|
||||
Lambda { params, body, .. } => {
|
||||
self.block(&body)?;
|
||||
for param in params.iter() {
|
||||
if let Some(ref expr) = param.default {
|
||||
@ -134,6 +141,34 @@ impl<'a> ScopeResolver<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn if_expr_body(&mut self, body: &IfExpressionBody) -> Result<(), String> {
|
||||
use IfExpressionBody::*;
|
||||
match body {
|
||||
SimpleConditional { then_case, else_case } => {
|
||||
self.block(then_case)?;
|
||||
if let Some(block) = else_case {
|
||||
self.block(block)?;
|
||||
}
|
||||
},
|
||||
SimplePatternMatch { pattern, then_case, else_case } => {
|
||||
self.pattern(pattern)?;
|
||||
self.block(then_case)?;
|
||||
if let Some(block) = else_case {
|
||||
self.block(block)?;
|
||||
}
|
||||
},
|
||||
CondList(conditions) => {
|
||||
for arm in conditions.iter() {
|
||||
if let Condition::Pattern(ref pat) = arm.condition {
|
||||
self.pattern(pat)?;
|
||||
}
|
||||
self.block(&arm.body)?;
|
||||
}
|
||||
},
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn pattern(&mut self, pat: &Pattern) -> Result<(), String> {
|
||||
use Pattern::*;
|
||||
match pat {
|
||||
|
Loading…
Reference in New Issue
Block a user