From 7b57fb6cc8710175012c2af733bcf21fa2aed646 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Thu, 10 Oct 2024 11:54:32 +0200 Subject: [PATCH 1/2] added test for #2049 --- .../rascal/tests/functionality/KeywordParameter.rsc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc index dded2d66327..8e59c4ff85d 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc @@ -337,4 +337,13 @@ int outer5(int t, int tabSize=4){ test bool outer5_1() = outer5(1) == 1; test bool outer5_11() = outer5(11) == 65; -test bool outer5_11_kw() = outer5(11, tabSize=40) == 101; \ No newline at end of file +test bool outer5_11_kw() = outer5(11, tabSize=40) == 101; + + +data WorkspaceInfo(rel[int a, int b] defines = {}) = workspaceInfo(); + +@synopsis{a test for issue #2049} +test bool staticTypesOfCommonKeywordDefaults() { + ws = workspaceInfo(); + return ws.defines == {}; +} From 8c88fb4e66723c03122a5114ae8ed1fc19db9dd0 Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Thu, 10 Oct 2024 11:54:45 +0200 Subject: [PATCH 2/2] fixes #2049 --- .../rascalmpl/interpreter/result/ConstructorFunction.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/interpreter/result/ConstructorFunction.java b/src/org/rascalmpl/interpreter/result/ConstructorFunction.java index 54fb43423f4..b7d602b6635 100644 --- a/src/org/rascalmpl/interpreter/result/ConstructorFunction.java +++ b/src/org/rascalmpl/interpreter/result/ConstructorFunction.java @@ -112,14 +112,17 @@ public Result computeDefaultKeywordParameter(String label, IConstructor kwResult = def.interpret(eval); } + // apply the static type we expect from the declaration: + kwResult = ResultFactory.makeResult(kwType, kwResult.getValue(), ctx); + if (name.equals(label)) { // we have the one we need, bail out quickly return kwResult; } else { - env.declareVariable(kwResult.getStaticType(), name); + env.declareVariable(kwType, name); env.storeVariable(name, kwResult); - resultEnv.declareVariable(kwResult.getStaticType(), name); + resultEnv.declareVariable(kwType, name); resultEnv.storeVariable(name, kwResult); } }