From 846d1726ef96d7e1b3e78f0e9600292cf8b78fdd Mon Sep 17 00:00:00 2001 From: pca006132 Date: Sat, 26 Feb 2022 16:34:01 +0800 Subject: [PATCH] nac3core: fixed keyword arguments handling --- nac3core/src/codegen/expr.rs | 3 +++ nac3core/src/typecheck/type_inferencer/mod.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/nac3core/src/codegen/expr.rs b/nac3core/src/codegen/expr.rs index 24467da7..975d0052 100644 --- a/nac3core/src/codegen/expr.rs +++ b/nac3core/src/codegen/expr.rs @@ -526,6 +526,9 @@ pub fn gen_call<'ctx, 'a, G: CodeGenerator>( } // default value handling for k in keys.into_iter() { + if mapping.get(&k.name).is_some() { + continue; + } mapping.insert( k.name, ctx.gen_symbol_val(generator, &k.default_value.unwrap()).into(), diff --git a/nac3core/src/typecheck/type_inferencer/mod.rs b/nac3core/src/typecheck/type_inferencer/mod.rs index 4a737761..58d7492d 100644 --- a/nac3core/src/typecheck/type_inferencer/mod.rs +++ b/nac3core/src/typecheck/type_inferencer/mod.rs @@ -809,7 +809,7 @@ impl<'a> Inferencer<'a> { posargs: args.iter().map(|v| v.custom.unwrap()).collect(), kwargs: keywords .iter() - .map(|v| (*v.node.arg.as_ref().unwrap(), v.custom.unwrap())) + .map(|v| (*v.node.arg.as_ref().unwrap(), v.node.value.custom.unwrap())) .collect(), fun: RefCell::new(None), ret: sign.ret,