From 2e74b49a5d1afede18a32e86857ed2ab6c01bd04 Mon Sep 17 00:00:00 2001 From: paulklint Date: Sat, 21 Nov 2026 12:50:29 +0100 Subject: [PATCH 01/15] Revert https://github.com/usethesource/rascal/commit/64c704b7e2905f754ef875093a22d0e69dbcaec7 --- .../lang/rascalcore/compile/Rascal2muRascal/RascalExpression.rsc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalExpression.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalExpression.rsc index c977867b4bf..c65110cf15c 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalExpression.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalExpression.rsc @@ -1807,6 +1807,7 @@ BTINFO getBTInfo(e:(Expression) ` \<- `, BTSCOPE bt MuExp translateGenerator(Expression current, Pattern pat, Expression exp, BTSCOPES btscopes, MuExp trueCont, MuExp falseCont){ expType = getType(exp); elemType = getElementType(expType); + if(isVoidAType(elemType)) return falseCont; loc fuid = topFunctionScope(); elem = muTmpIValue(nextTmp("elem"), fuid, elemType); From 4da8b27146c020a27a794463f4b3a468a77b5cc4 Mon Sep 17 00:00:00 2001 From: paulklint Date: Mon, 23 Nov 2026 14:08:52 +0100 Subject: [PATCH 02/15] Ignore function only used in interpreter-based test --- src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc b/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc index 375832d1051..479527d7dad 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/basic/Functions.rsc @@ -648,6 +648,8 @@ test bool voidInitializerIsRejected() { } data Article = article(str name); + +@ignoreCompiler{The type checker rejects the overloading with the above constructor} void article(value args...) {} // The ADT qualifier excludes the void function, so only the constructor remains From b3189a2904c026f2febae598f977609b1f022196 Mon Sep 17 00:00:00 2001 From: paulklint Date: Mon, 23 Nov 2026 14:09:49 +0100 Subject: [PATCH 03/15] Fixed handling of keywaord parameters in closures --- .../lang/rascalcore/compile/muRascal2Java/CodeGen.rsc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc index 273f5b44dba..a8abe3a127c 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc @@ -606,7 +606,8 @@ JCode trans(muOFun(list[FUNID] funIds, AType ftype), JGenie jg){ fun = muFunctions[funId]; fun_kwFormals += fun.ftype.kwFormals; if(!isEmpty(fun.externalRefs)){ - ext_actuals += [varName(v, jg) | v <- fun.externalRefs]; + //ext_actuals += [varName(v, jg) | v <- fun.externalRefs]; + ext_actuals += [newValueRef(varName(v, jg), getType(v), v, jg) | v <- fun.externalRefs]; } } } @@ -620,7 +621,8 @@ JCode trans(muOFun(list[FUNID] funIds, AType ftype), JGenie jg){ formalsAsStr = intercalate(", ", formals); actualsWithCastAsStr = intercalate(", ", actualsWithCast); - return "(() -\> { return (); }, )"; + res = "(() -\> { return (); }, )"; + return res; } // ---- muComposedFun --------------------------------------------------------- From 2a198bb4dc133deb95af1e992aa2d6ed1d1cbd44 Mon Sep 17 00:00:00 2001 From: paulklint Date: Mon, 23 Nov 2026 14:12:14 +0100 Subject: [PATCH 04/15] Made rascalMayOverload more precise + code cleanup --- .../lang/rascalcore/check/RascalConfig.rsc | 60 +++---------------- 1 file changed, 7 insertions(+), 53 deletions(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc index d8f4e7a2688..173fc5a89c2 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc @@ -39,6 +39,7 @@ import lang::rascalcore::compile::muRascal::AST; import lang::rascalcore::check::CheckerCommon; import lang::rascalcore::check::BasicRascalConfig; import lang::rascalcore::check::ModuleLocations; +import lang::rascalcore::check::LogicalLocations; import Location; import util::FileSystem; @@ -77,62 +78,15 @@ bool rascalMayOverload(set[loc] defs, map[loc, Define] defines){ } } } - - // oldResult = rascalMayOverloadOld(defs, defines); - // if(result != oldResult){ - // println("rascalMayOverload, new: , old: , for "); - // for(def <- defs){ - // println(defines[def]); - // } - // throw "rascalMayOverload"; - // } + if(result){ + scopes = {defines[d].scope | d <- defs}; + if(size(scopes) != 1){ + result = all(s <- scopes, isModuleId(s)) || all(s <- scopes, isFunctionId(s)); + } + } return result; } -// // Define the name overloading that is allowed -// bool rascalMayOverloadOld(set[loc] defs, map[loc, Define] defines){ -// bool seenVAR = false; -// bool seenNT = false; -// bool seenLEX = false; -// bool seenLAY = false; -// bool seenKEY = false; -// bool seenALIAS = false; -// bool seenFUNCTION = false; - -// for(def <- defs){ -// // Forbid: -// // - overloading of variables/formals/pattern variables -// // - overloading of incompatible syntax definitions -// // - alias and most other names -// switch(defines[def].idRole){ -// case functionId(): -// { if(seenVAR || seenALIAS) return false; seenFUNCTION = true; } -// case variableId(): -// { if(seenVAR || seenFUNCTION || seenALIAS) return false; seenVAR = true;} -// case moduleVariableId(): -// { if(seenVAR || seenFUNCTION || seenALIAS) return false; seenVAR = true;} -// case formalId(): -// { if(seenVAR || seenFUNCTION || seenALIAS) return false; seenVAR = true;} -// case keywordFormalId(): -// { if(seenVAR || seenFUNCTION || seenALIAS) return false; seenVAR = true;} -// case patternVariableId(): -// { if(seenVAR || seenFUNCTION || seenALIAS) return false; seenVAR = true;} -// case nonterminalId(): -// { if(seenLEX || seenLAY || seenKEY || seenALIAS){ return false; } seenNT = true; } -// case lexicalId(): -// { if(seenNT || seenLAY || seenKEY || seenALIAS) { return false; } seenLEX= true; } -// case layoutId(): -// { if(seenNT || seenLEX || seenKEY || seenALIAS) { return false; } seenLAY = true; } -// case keywordId(): -// { if(seenNT || seenLAY || seenLEX || seenALIAS) { return false; } seenKEY = true; } -// case aliasId(): -// { if(seenALIAS || seenVAR || seenFUNCTION || seenNT || seenLEX || seenLAY || seenKEY) return false; seenALIAS = true; } -// } -// } -// return true; -// } - - // Name resolution filters set[IdRole] defBeforeUseRoles = {variableId(), moduleVariableId(), formalId(), keywordFormalId(), patternVariableId()}; From 58c59cfe691c4090c4084be0cf94a51208aa4f36 Mon Sep 17 00:00:00 2001 From: paulklint Date: Mon, 30 Nov 2026 23:34:47 +0100 Subject: [PATCH 05/15] Fixed logical/physical confusion --- .../compiler/lang/rascalcore/check/RascalConfig.rsc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc index 173fc5a89c2..169fcdb9ccb 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc @@ -403,6 +403,8 @@ void checkOverloading(map[str,Tree] namedTrees, Solver s){ facts = s.getFacts(); moduleScopes = { t.src | t <- range(namedTrees) }; + bool definedInReachableModule(loc l) = isModuleId(l) && any(ms <- moduleScopes, s.isContainedIn(l, ms)); + funDefs = { | define <- defines, define.idRole == functionId() }; funIds = domain(funDefs); for(id <- funIds){ @@ -411,7 +413,8 @@ void checkOverloading(map[str,Tree] namedTrees, Solver s){ for(d1 <- defs, d2 <- defs, d1.defined != d2.defined, d1.defined in facts, AType t1 := facts[d1.defined], d2.defined in facts, AType t2 := facts[d2.defined], - d1.scope in moduleScopes, d2.scope in moduleScopes, size(t1.formals) == size(t2.formals) + size(t1.formals) == size(t2.formals), + definedInReachableModule(d1.scope), definedInReachableModule(d2.scope) ){ if(isEmpty(t1.formals)){ msgs = [ error("Nullary function `` should not be overloaded", d1.defined), From 84845b04b0becf101b65b46fe4f70fe150401c30 Mon Sep 17 00:00:00 2001 From: paulklint Date: Mon, 30 Nov 2026 23:35:38 +0100 Subject: [PATCH 06/15] Rewritten code that is not handled properly by the compiler --- src/org/rascalmpl/library/lang/html5/DOM.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/rascalmpl/library/lang/html5/DOM.rsc b/src/org/rascalmpl/library/lang/html5/DOM.rsc index 79127968a1d..70801d74029 100644 --- a/src/org/rascalmpl/library/lang/html5/DOM.rsc +++ b/src/org/rascalmpl/library/lang/html5/DOM.rsc @@ -456,6 +456,6 @@ private HTML5Node example @synopsis{pretty print HTML5Node DOM to a string} str toString(HTML5Node x) { attrs = { k | HTML5Attr k <- x.kids }; - kids = [ k | value k <- x.kids, !(HTML5Attr _ := k) ]; + kids = [ k | value k <- x.kids, HTML5Attr _ !:= k ]; return nodeToString(x.name, attrs, kids); } \ No newline at end of file From 46419890533492d64c34f158e0c0c8495ee43888 Mon Sep 17 00:00:00 2001 From: paulklint Date: Mon, 30 Nov 2026 23:36:19 +0100 Subject: [PATCH 07/15] Fixed incorrect handling of keyword parameters --- .../compile/muRascal2Java/Resolvers.rsc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc index db23c7411e6..d1885bc24e0 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/Resolvers.rsc @@ -425,7 +425,7 @@ str generateResolver(MODID moduleId, str functionName, set[Define] fun_defs, map call_actuals += "() $P"; } - actuals_text = intercalate(", ", call_actuals); + actuals_base = intercalate(", ", call_actuals); activeKwpFormals = []; if(def in relevant_fun_defs /*local_fun_defs*/){ @@ -436,22 +436,24 @@ str generateResolver(MODID moduleId, str functionName, set[Define] fun_defs, map activeKwpFormals += tp.kwFormals; } } + + actuals_with_kwp = actuals_base; if(hasKeywordParameters(def_type) /*|| (def.scope notin module_scopes && !isEmpty(activeKwpFormals))*/){ - actuals_text = isEmpty(actuals_text) ? "$kwpActuals" : ", $kwpActuals"; + actuals_with_kwp = isEmpty(actuals_base) ? "$kwpActuals" : ", $kwpActuals"; } if(!onlyGlobalFuns){ externalRefs = getExternalRefs(def, fid2muFunction); if(!isEmpty(externalRefs)){ - actuals_text += (isEmpty(actuals_text) ? "" : ", ") + intercalate(", ", [ varName(var) | var <- externalRefs ]); + actuals_with_kwp += (isEmpty(actuals_with_kwp) ? "" : ", ") + intercalate(", ", [ varName(var) | var <- externalRefs ]); } } key = isConstructorAType(def_type) ? 0 : (def_type.isConcreteArg ? def_type.concreteFingerprint : def_type.abstractFingerprint); //key = /*def_type.isDefault ? 0 :*/ (def_type.isConcreteArg ? def_type.concreteFingerprint : def_type.abstractFingerprint); call_code = base_call = ""; - cst = resolver_returns_void ? "" : "()"; if(isFunctionAType(def_type)){ + cst = resolver_returns_void ? "" : "()"; if(jg.isContainedIn(def.defined, module_scope)){ pref = ""; if(def.scope != module_scope){ @@ -461,9 +463,9 @@ str generateResolver(MODID moduleId, str functionName, set[Define] fun_defs, map } } } - call_code = "()"; + call_code = "()"; } else if(/*jg.isContainedIn(def.defined, def.scope),*/ def.scope in module_scopes){ - call_code = ".()"; // was uniqueName + call_code = ".()"; // was uniqueName } else { return; //do nothing } @@ -475,9 +477,9 @@ str generateResolver(MODID moduleId, str functionName, set[Define] fun_defs, map } } else { if(hasKeywordParameters(def_type)){ - base_call = "return $RVF.constructor(, new IValue[]{}, $kwpActuals);"; + base_call = "return $RVF.constructor(, new IValue[]{}, $kwpActuals);"; } else { - base_call = "return $RVF.constructor(, new IValue[]{});"; + base_call = "return $RVF.constructor(, new IValue[]{});"; } } From 4c862c872e63f07aab93cce5f5295d524e854b98 Mon Sep 17 00:00:00 2001 From: paulklint Date: Mon, 30 Nov 2026 23:37:59 +0100 Subject: [PATCH 08/15] Commented out redundant transformation --- .../compile/Rascal2muRascal/RascalPattern.rsc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalPattern.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalPattern.rsc index e1abcea5fb5..9a0aa196b29 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalPattern.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Rascal2muRascal/RascalPattern.rsc @@ -1160,11 +1160,13 @@ MuExp translatePat(p:(Pattern) ` ( <{Pattern ","}* arguments MuExp arg_val = muTmpIValue(nextTmp("arg_"), fuid, avalue()); AType arg_type = getType(lpats[i]); + //TODO: can we really do without this code? // Replace all occurrences of the argument by the var representing its computed value - body = visit(body){ - case muVar(str name, loc fuid, int pos, AType atype, IdRole idRole) => arg_val - when name == arg_type.alabel, arg_type := atype - }; + // body = visit(body){ + // case m:muVar(str name, loc fuid, int pos, AType atype, IdRole idRole) => arg_val + // when name == arg_type.alabel, arg_type := atype, bprintln(" =\> ") + // }; + // iprintln(body); body = muBlock([ muVarInit(arg_val, arg), muIfElse(muValueIsComparable(arg_val, arg_type), @@ -1191,11 +1193,12 @@ MuExp translatePat(p:(Pattern) ` ( <{Pattern ","}* arguments } fun_name = asUnqualifiedName(prettyPrintName(qname)); code = muBlock([subjectInit, muIfElse(muHasNameAndArity(subjectType, expType, muCon(fun_name), size(lpats), subject), body, falseCont)]); - + // iprintln(code); return code; } else if(expression is literal){ // StringConstant fun_name = prettyPrintName(""[1..-1]); //TODO escapes in string code = muBlock([subjectInit, muIfElse(muHasNameAndArity(subjectType, expType, muCon(fun_name), size(lpats), subject), body, falseCont)]); + // iprintln(code); return code; } else { fun_name_subject = muTmpIValue(nextTmp("fun_name_subject"), fuid, expType); @@ -1212,6 +1215,7 @@ MuExp translatePat(p:(Pattern) ` ( <{Pattern ","}* arguments ]); } code = muExists(getEnter(p, btscopes), code); +// iprintln(code); return code; } From 59c39145e2af687c5287655459457d98e273f51a Mon Sep 17 00:00:00 2001 From: paulklint Date: Mon, 30 Nov 2026 23:38:29 +0100 Subject: [PATCH 09/15] Renamed illegal overloading of "benchmark". --- .../lang/rascal/tests/concrete/recovery/ParseBenchmark.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ParseBenchmark.rsc b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ParseBenchmark.rsc index e7bb923bebe..af2197792f0 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ParseBenchmark.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/concrete/recovery/ParseBenchmark.rsc @@ -91,7 +91,7 @@ private str syntaxLocToModuleName(loc syntaxFile) { } -private void benchmark(ParseBenchmarkConfig config) { +private void parserBenchmark(ParseBenchmarkConfig config) { writeFile(config.statFile, "input,size,duration\n"); Module \module = parse(#start[Module], config.syntaxFile).top; str modName = syntaxLocToModuleName(config.syntaxFile); @@ -128,7 +128,7 @@ int main(list[str] args) { } } - benchmark(config); + parserBenchmark(config); return 0; } From c40cf92cc23bb4bfb663462655f83c1055a8a89f Mon Sep 17 00:00:00 2001 From: paulklint Date: Mon, 30 Nov 2026 23:39:24 +0100 Subject: [PATCH 10/15] Fixed various issues --- rascal.code-workspace | 3 + .../lang/rascalcore/compile/Examples/Tst4.rsc | 70 ++++++++++++++++--- .../compile/muRascal2Java/CodeGen.rsc | 34 +++++---- .../lang/rascalcore/compile/util/Names.rsc | 17 ++--- 4 files changed, 94 insertions(+), 30 deletions(-) diff --git a/rascal.code-workspace b/rascal.code-workspace index d885fe36eae..785db1bfba2 100644 --- a/rascal.code-workspace +++ b/rascal.code-workspace @@ -5,6 +5,9 @@ }, { "path": "../typepal" + }, + { + "path": "../compiled-rascal" } ], "settings": { diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst4.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst4.rsc index 542355435cc..ad1a6e5ac26 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst4.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/Examples/Tst4.rsc @@ -24,14 +24,64 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. } -module lang::rascalcore::compile::Examples::Tst4 - -@synopsis{Pretty prints nodes and ADTs using ASCII art for the edges.} -str prettyNode(bool keywords=true) { - lrel[str,value] edges(node k) = [] when keywords; - default lrel[str,value] edges(value _) = []; - - return ppvalue(edges); +module lang::rascalcore::compile::Examples::Tst4 +import Content; + +str f(str s, bool b = false) = "xxx"; + +void xxx(bool b = false){ + Response reply(get(/^\/cytoscape$/)) { + return response("abc", f); + } } -private str ppvalue(lrel[str,value](value) edges) = ""; - \ No newline at end of file + +// public map[str,num] benchmark(map[str, void()] Cases) { +// return (); +// } + +// private void benchmark(int n) { +// } + + +// data Calculator; +// Calculator id(Calculator calc) = calc; +// void f(){ +// value currentAction = 0; + +// void checkDep(loc l){ +// if(Calculator calc := currentAction){ +// id(calc); +// } +// } +// } + +// data D = d(int n, str s) | e(int n, str s); + +// int f(D x){ +// if(d(n, _) := x){ +// return n; +// } else if(e(n, _) := x){ +// return n; +// } +// return -1; +// } + +// import analysis::typepal::ISolver; +// import lang::rascalcore::check::AType; + +// extend lang::rascalcore::check::ATypeInstantiation; + +// void xxx (QualifiedName n, Solver s){ +// baseType = s.getType(n); +// if(aadt(adtName, params1, _) := baseType){ +// ; +// } else if(aalias(aname, params2, aliased) := baseType){ +// ; +// } +// } + +// void toString(list[int] x) { +// for(int k <- x, !(3 := k)){ +// ; +// } +// } \ No newline at end of file diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc index a8abe3a127c..fda95dce052 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc @@ -115,9 +115,15 @@ tuple[JCode, JCode, JCode, list[value]] muRascal2Java(MuModule m, ModuleStatus m bool hasMainFunction = false; str mainName = "main"; AType mainType = avoid(); + bool isMainType(AType atype){ + assert isFunctionAType(atype); + argTypes = getFunctionOrConstructorArgumentTypes(atype); + return argTypes == [] || [alist(astr())] := argTypes; + + } MuFunction mainFunction; for(f <- m.functions){ - if(isOuterScopeName(f.scopeIn) && isMainName(f.name)) { + if(isOuterScopeName(f.scopeIn) && isMainName(f.name) && isMainType(f.ftype)) { hasMainFunction = true; mainFunction = f; mainType = f.ftype; @@ -306,9 +312,12 @@ tuple[JCode, JCode, JCode, list[value]] muRascal2Java(MuModule m, ModuleStatus m str newValueRef(str name, str jtype, str code, JGenie jg) = "new ValueRef\<\>(\"\", )"; -str newValueRef(str vname, AType atype, v:muVar(str name, loc _, int pos, AType _, IdRole idRole), JGenie jg) - = jg.isRef(v) ? "new ValueRef\<\>(\"\", .getValue())" : newValueRef(vname, atype2javatype(atype), varName(v, jg), jg) +str newValueRef(str vname, AType atype, v:muVar(str name, loc _, int pos, AType _, IdRole idRole), JGenie jg){ + jtype = atype2javatype(atype); + res = jg.isRef(v) ? "new ValueRef\<\>(\"\", .getValue())" : newValueRef(vname, jtype, varName(v, jg), jg) ; + return res; +} default str newValueRef(str name, AType atype, MuExp exp, JGenie jg) = "new ValueRef\<\>(\"\", )"; @@ -552,7 +561,8 @@ JCode trans(muFun(FUNID uid, AType ftype), JGenie jg){ actuals = intercalate(", ", [")">$_" | i <- [0..nformals]]); if(!isEmpty(ftype.kwFormals)){ - actuals = isEmpty(actuals) ? "$kwpActuals" : ", $kwpActuals"; + // actuals = isEmpty(actuals) ? "$kwpActuals" : ", $kwpActuals"; + actuals = isEmpty(actuals) ? " Util.kwpMap()" : ", Util.kwpMap()"; } // else if(muFunctions[uid]?){ // fun = muFunctions[uid]; @@ -613,7 +623,8 @@ JCode trans(muOFun(list[FUNID] funIds, AType ftype), JGenie jg){ } if(!isEmpty(fun_kwFormals)){ - actualsWithCast += ["$kwpActuals"]; + // actualsWithCast += ["$kwpActuals"]; + actualsWithCast += ["Util.kwpMap()"]; } actualsWithCast += ext_actuals; @@ -780,10 +791,8 @@ JCode trans(muVarInit(v: muVar(str name, loc fuid, int pos, AType atype, IdRole } else if(isSameVarModuloRole(v, exp)) { return ""; } else { - x = varName(v, jg); - y = newValueRef(name, atype, exp, jg); return jg.isRef(v) ? "final ValueRef\<\> = ;\n" //new ValueRef\<\>();\n" - : " = ;\n"; + : " = ();\n"; } } @@ -825,11 +834,11 @@ JCode trans(muVarInit(var: muTmpNative(str name, loc fuid, NativeKind nkind), Mu if(isSameVarModuloRole(v, exp)){ return ""; } - jtype = atype2javatype(atype); + jtype = atype2javatype(alub(atype, getType(exp))); if(jg.isRef(v)){ return "final ValueRef\<\> = ;\n"; //new ValueRef\<\>();\n"; } - return " = ;\n"; + return " = ();\n"; } JCode trans(muConInit(v:muTmpIValue(str name, loc fuid, AType atype), MuExp exp), JGenie jg){ @@ -1042,7 +1051,8 @@ JCode trans(muReturnFirstSucceeds(list[str] formals, list[MuExp] exps), JGenie j // ---- muGetKwField ------------------------------------------------------ str prefix(str moduleName, JGenie jg){ - res = (isEmpty(moduleName) || isEqualModule(moduleName, jg.getModuleName())) ? "" : (module2field(moduleName) + "."); + mn = jg.getModuleName(); + res = (isEmpty(moduleName) || moduleName == jg.getModuleName()) ? "" : (module2field(moduleName) + "."); return res; } JCode trans(muGetKwField(AType resultType, adtType:aadt(_,_,_), MuExp cons, str fieldName, str moduleName), JGenie jg){ @@ -1387,7 +1397,7 @@ JCode trans(muHasKwp(MuExp exp, str kwName), JGenie jg) JCode trans(muGetKwp(MuExp exp, AType atype, str kwpName), JGenie jg){ if(acons(AType adtType, list[AType] _, list[Keyword] _) := atype){ adtName = getUniqueADTName(adtType); - return "$getkw__()"; + return "$getkw__()"; } else if(anode(_) := atype){ return ".asWithKeywordParameters().getParameter(\"\")"; } else if(a: aadt(str _, list[AType] _, SyntaxRole _) := atype){ diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/util/Names.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/util/Names.rsc index cb8a17ba40e..fdaeebb3164 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/util/Names.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/util/Names.rsc @@ -26,6 +26,7 @@ POSSIBILITY OF SUCH DAMAGE. } module lang::rascalcore::compile::util::Names +import IO; import String; import List; import util::Reflective; @@ -267,12 +268,12 @@ str unescapeName(str s){ return s[0] == "\\" ? s[1..] : s; } -bool isEqualModule(str name1, name2){ - if(contains(name1, "::") && contains(name2, "::")) return name1 == name2; - name1a = replaceAll(name1, "::", "_"); - name2a = replaceAll(name2, "::", "_"); - res = endsWith(name1a, name2a) || endsWith(name2a, name1a); - //println("isEqualModule(, ) =\> "); - return res; -} +// bool isEqualModule(str name1, name2){ +// if(contains(name1, "::") && contains(name2, "::")) return name1 == name2; +// name1a = replaceAll(name1, "::", "_"); +// name2a = replaceAll(name2, "::", "_"); +// res = endsWith(name1a, name2a) || endsWith(name2a, name1a); +// // println("isEqualModule(, ) =\> "); +// return res; +// } From 4483c4c09b0e9e3bad56398aeef52cb7281cbfeb Mon Sep 17 00:00:00 2001 From: paulklint Date: Tue, 1 Dec 2026 09:22:22 +0100 Subject: [PATCH 11/15] Fixed consequences of stricter check --- .../lang/rascalcore/check/tests/DeclarationTCTests.rsc | 4 ++-- .../lang/rascalcore/check/tests/StaticTestingUtils.rsc | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc index 41b254de187..64ece86e743 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc @@ -522,8 +522,8 @@ test bool overloadedVoidFunctionInitializerIsRejected() = checkModuleAndFilter(" void main() { int a = f(1); } ", ["Variable initialization should not have type `void`"]); -test bool nonMatchingVoidOverloadInitializerIsAccepted() = checkModuleOK(" - module NonMatchingVoidOverloadInitializerIsAccepted +test bool nonMatchingVoidOverloadInitializerIsNotAccepted() = checkModuleOK(" + module NonMatchingVoidOverloadInitializerIsNotAccepted int f(int x) = x; void f(str x) {} void main() { int a = f(1); } diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc index c56ef6374d6..ae116cc323e 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc @@ -477,7 +477,8 @@ list[str] unexpectedDeclarationMsgs = [ "Self import not allowed", "Extend cycle not allowed", "Mixed import/extend cycle not allowed", - "Module name _ is incompatible with its file location" + "Module name _ is incompatible with its file location", + "Declaration clashes with other declaration of function _ with non-`void` result type" ]; bool unexpectedDeclarationInModule(str moduleText, PathConfig pathConfig = getDefaultTestingPathConfig()) From a64113acd057c4e85f8fc58813a62c3024d6acb5 Mon Sep 17 00:00:00 2001 From: paulklint Date: Tue, 1 Dec 2026 09:50:42 +0100 Subject: [PATCH 12/15] Fixed incorrect fix --- .../lang/rascalcore/check/tests/DeclarationTCTests.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc index 64ece86e743..79258540d61 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/DeclarationTCTests.rsc @@ -522,12 +522,12 @@ test bool overloadedVoidFunctionInitializerIsRejected() = checkModuleAndFilter(" void main() { int a = f(1); } ", ["Variable initialization should not have type `void`"]); -test bool nonMatchingVoidOverloadInitializerIsNotAccepted() = checkModuleOK(" +test bool nonMatchingVoidOverloadInitializerIsNotAccepted() = checkModuleAndFilter(" module NonMatchingVoidOverloadInitializerIsNotAccepted int f(int x) = x; void f(str x) {} void main() { int a = f(1); } - "); + ", ["Declaration clashes with other declaration of function _ with non-`void` result type"]); test bool voidKeywordParameterDefaultIsRejected() = checkModuleAndFilter(" module VoidKeywordParameterDefaultIsRejected From 237dc60ef70d0a22b1f1267b0b645fb4fa85e603 Mon Sep 17 00:00:00 2001 From: paulklint Date: Tue, 1 Dec 2026 21:46:01 +0100 Subject: [PATCH 13/15] Fixed handling of main function --- .../lang/rascalcore/compile/muRascal2Java/CodeGen.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc index fda95dce052..1f4b24f2236 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/compile/muRascal2Java/CodeGen.rsc @@ -1002,9 +1002,9 @@ JCode trans(muOCall(MuExp fun, AType ftype, list[MuExp] largs, lrel[str kwpName, if(jg.isContainedIn(uid, jg.getModuleLoc())){ fn = muFunctions[uid]; arg_list = "()"; - + fun_name = isGlobalScope(fn.scopeIn) - ? "$me." + ? (isMainName(fn.name) ? fn.name : "$me.") : (isClosureName(fn.name) ? fn.name : jg.getFunctionNameInContext(fn.scopeIn, fn.name) From 6dddab7d4473f596280454f087c6dea8b8060f3b Mon Sep 17 00:00:00 2001 From: paulklint Date: Thu, 3 Dec 2026 18:57:04 +0100 Subject: [PATCH 14/15] Fixed extra check in rascalMayOverload --- .../rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc index 169fcdb9ccb..bd864da0dec 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc @@ -81,7 +81,7 @@ bool rascalMayOverload(set[loc] defs, map[loc, Define] defines){ if(result){ scopes = {defines[d].scope | d <- defs}; if(size(scopes) != 1){ - result = all(s <- scopes, isModuleId(s)) || all(s <- scopes, isFunctionId(s)); + result = all(s <- scopes, s in defines, defines[s].idRole == moduleId()); } } return result; From 6800abbe323b8ccd7b579185adc70c7a8ab8854f Mon Sep 17 00:00:00 2001 From: paulklint Date: Thu, 3 Dec 2026 20:34:00 +0100 Subject: [PATCH 15/15] Commented out problematic test --- .../compiler/lang/rascalcore/check/RascalConfig.rsc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc index bd864da0dec..35b5214720a 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/RascalConfig.rsc @@ -78,12 +78,12 @@ bool rascalMayOverload(set[loc] defs, map[loc, Define] defines){ } } } - if(result){ - scopes = {defines[d].scope | d <- defs}; - if(size(scopes) != 1){ - result = all(s <- scopes, s in defines, defines[s].idRole == moduleId()); - } - } + // if(result){ + // scopes = {defines[d].scope | d <- defs}; + // if(size(scopes) != 1){ + // result = all(s <- scopes, s in defines, defines[s].idRole == moduleId()); + // } + // } return result; }