typecheck_expr doesnt need to mutate the TypeChecker
This commit is contained in:
@@ -564,7 +564,7 @@ _builtin_environ:
|
|||||||
} else {
|
} else {
|
||||||
let var = match env.get_var(&name.lexeme) {
|
let var = match env.get_var(&name.lexeme) {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => unreachable!(),
|
None => unreachable!("this should be caught in the typechecker"),
|
||||||
};
|
};
|
||||||
emit!(
|
emit!(
|
||||||
&mut self.output,
|
&mut self.output,
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ impl<'a> TypeChecker<'a> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn typecheck_expr(&mut self, env: &mut Env, expr: &Expr) -> Result<Type, ZernError> {
|
pub fn typecheck_expr(&self, env: &mut Env, expr: &Expr) -> Result<Type, ZernError> {
|
||||||
match expr {
|
match expr {
|
||||||
Expr::Binary { left, op, right } => {
|
Expr::Binary { left, op, right } => {
|
||||||
let left_type = self.typecheck_expr(env, left)?;
|
let left_type = self.typecheck_expr(env, left)?;
|
||||||
@@ -370,7 +370,7 @@ impl<'a> TypeChecker<'a> {
|
|||||||
} => {
|
} => {
|
||||||
if let Expr::Variable(callee_name) = &**callee {
|
if let Expr::Variable(callee_name) = &**callee {
|
||||||
if self.analyzer.functions.contains_key(&callee_name.lexeme) {
|
if self.analyzer.functions.contains_key(&callee_name.lexeme) {
|
||||||
let fn_type = &self.analyzer.functions[&callee_name.lexeme].clone();
|
let fn_type = &self.analyzer.functions[&callee_name.lexeme];
|
||||||
// its a function (defined/builtin/extern)
|
// its a function (defined/builtin/extern)
|
||||||
if let Some(params) = fn_type.params.clone() {
|
if let Some(params) = fn_type.params.clone() {
|
||||||
for (i, arg) in args.iter().enumerate() {
|
for (i, arg) in args.iter().enumerate() {
|
||||||
|
|||||||
Reference in New Issue
Block a user