diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectExpression.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectExpression.rsc index 34e2e20b..327d4044 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectExpression.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/check/CollectExpression.rsc @@ -565,17 +565,21 @@ void collect(current: (Expression) ` ( <{Expression ","}* } return aloc(); } - if(isConstructorAType(texp) && getConstructorResultType(texp).adtName == "Tree" && "" == "char"){ - nactuals = size(actuals); - if(nactuals != 1){ - s.report(error(current, "`char` requires 1 argument, found %v", nactuals)); + + if(isConstructorAType(texp) && getConstructorResultType(texp).adtName == "Tree" && expression is qualifiedName){ + = splitQualifiedName(expression.qualifiedName); + if (base == "char" && (isEmpty(qualifier) || qualifier == "Tree")){ + nactuals = size(actuals); + if(nactuals != 1){ + s.report(error(current, "`char` requires 1 argument, found %v", nactuals)); + } + s.requireEqual(actuals[0], aint(), error(actuals[0], "Argument should be of type `int`, found %t", actuals[0])); + if(actuals[0] is literal){ + chr = toInt(""); + return \achar-class([arange(chr, chr)]); + } else + return anyCharType; } - s.requireEqual(actuals[0], aint(), error(actuals[0], "Argument should be of type `int`, found %t", actuals[0])); - if(actuals[0] is literal){ - chr = toInt(""); - return \achar-class([arange(chr, chr)]); - } else - return anyCharType; } if(overloadedAType(rel[loc, IdRole, AType] overloads) := texp){ diff --git a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc index 9b5e11df..e3d8d863 100644 --- a/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc +++ b/src/org/rascalmpl/core/library/lang/rascalcore/compile/Examples/Tst4.rsc @@ -1,69 +1,19 @@ module lang::rascalcore::compile::Examples::Tst4 -import lang::rascalcore::check::Checker; -import lang::rascalcore::check::BasicRascalConfig; -import lang::rascalcore::check::RascalConfig; -import IO; -import Message; -import Map; -import util::FileSystem; -import util::Reflective; - -tuple[PathConfig, RascalCompilerConfig] testConfigs(loc projectPath) { - pcfg = pathConfig( - bin=projectPath + "bin", - libs=[|home:///.m2/repository/org/rascalmpl/rascal/0.40.10/rascal-0.40.10.jar|], - srcs=[projectPath + "src"], - resources=projectPath + "resources", - generatedSources=projectPath + "generated-sources" - ); - - RascalCompilerConfig ccfg = rascalCompilerConfig(pcfg) - [forceCompilationTopModule = true] - [verbose = true]; - - return ; -} - -ModuleStatus checkModule(loc projectPath, str moduleName, str moduleBody, RascalCompilerConfig ccfg) { - modulePath = projectPath + "src" + ".rsc"; - writeFile(modulePath, moduleBody); - return rascalTModelForLocs([modulePath], ccfg, dummy_compile1); -} -void noTmodel(loc projectPath = |memory:///NoTModelTest|) { - remove(projectPath); - = testConfigs(projectPath); - - moduleName = "M"; - moduleStr = " - 'module - ' - 'void main() { - ' int foo = x + y; - '} - "; - - if(ms := checkModule(projectPath, moduleName, moduleStr, ccfg)) { - if (size(ms.tmodels) > 0) { // This branch is expected to be taken - println("Success!"); - } else { // This branch is taken instead - println("Failure..."); - println("TModels: "); - } - } else { - println("checkModule failed"); - } -} - -// import ParseTree; -// import String; +import ParseTree; +import String; // public str squeeze(str src, type[&CharClass <: ![]] _) = visit(src) { // case /+/ => c -// when &CharClass _ := Tree::char(charAt(c, 0)) +// when &CharClass _ := char(charAt(c, 0)) // }; +value main(){ + ![] x = Tree:: /* xxxx */ char(charAt("a", 0)); + return x; +} + // void f(int n){ // [x | x <- [0..n], [x] := [x], x > 0]; // }