rascal

Error passing function result as parameter


I am having an issue passing my function result as parameter to another function, when I try to run the function below;

lrel[loc location,str action_type]temp = getScripts("ptl/src/reverseengineering/examples/testbed/workflows");
result = generatePTLAST(temp);

I get a rascal internal error;

io.usethesource.vallang.exceptions.RedeclaredConstructorException: Constructor quotedIdentifier overloaded with comparable argument types: tuple[str quotedId] and tuple[str name]
(internal error)
        at $shell$(|main://$shell$|)

io.usethesource.vallang.exceptions.RedeclaredConstructorException: Constructor quotedIdentifier overloaded with comparable argument types: tuple[str quotedId] and tuple[str name]
        at io.usethesource.vallang.type.TypeStore.checkOverloading(TypeStore.java:393)
        at io.usethesource.vallang.type.TypeStore.declareConstructor(TypeStore.java:337)
        at io.usethesource.vallang.type.TypeFactory.constructorFromTuple(TypeFactory.java:608)
        at io.usethesource.vallang.type.ConstructorType$Info.fromProduction(ConstructorType.java:118)
        at io.usethesource.vallang.type.AbstractDataType$Info.fromSymbol(AbstractDataType.java:126)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbols(TypeFactory.java:1135)
        at io.usethesource.vallang.type.ConstructorType$Info.fromProduction(ConstructorType.java:118)
        at io.usethesource.vallang.type.AbstractDataType$Info.fromSymbol(AbstractDataType.java:126)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.ListType$Info.fromSymbol(ListType.java:53)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbols(TypeFactory.java:1135)
        at io.usethesource.vallang.type.ConstructorType$Info.fromProduction(ConstructorType.java:118)
        at io.usethesource.vallang.type.AbstractDataType$Info.fromSymbol(AbstractDataType.java:126)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbols(TypeFactory.java:1135)
        at io.usethesource.vallang.type.ConstructorType$Info.fromProduction(ConstructorType.java:118)
        at io.usethesource.vallang.type.AbstractDataType$Info.fromSymbol(AbstractDataType.java:126)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.ListType$Info.fromSymbol(ListType.java:53)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbols(TypeFactory.java:1135)
        at io.usethesource.vallang.type.ConstructorType$Info.fromProduction(ConstructorType.java:118)
        at io.usethesource.vallang.type.AbstractDataType$Info.fromSymbol(AbstractDataType.java:126)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbols(TypeFactory.java:1135)
        at io.usethesource.vallang.type.ConstructorType$Info.fromProduction(ConstructorType.java:118)
        at io.usethesource.vallang.type.AbstractDataType$Info.fromSymbol(AbstractDataType.java:126)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbols(TypeFactory.java:1135)
        at io.usethesource.vallang.type.ConstructorType$Info.fromProduction(ConstructorType.java:118)
        at io.usethesource.vallang.type.AbstractDataType$Info.fromSymbol(AbstractDataType.java:126)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbols(TypeFactory.java:1135)
        at io.usethesource.vallang.type.ConstructorType$Info.fromProduction(ConstructorType.java:118)
        at io.usethesource.vallang.type.AbstractDataType$Info.fromSymbol(AbstractDataType.java:126)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbols(TypeFactory.java:1135)
        at io.usethesource.vallang.type.ConstructorType$Info.fromProduction(ConstructorType.java:118)
        at io.usethesource.vallang.type.AbstractDataType$Info.fromSymbol(AbstractDataType.java:126)
        at io.usethesource.vallang.type.TypeFactory$TypeValues.fromSymbol(TypeFactory.java:1111)
        at io.usethesource.vallang.type.TypeFactory.fromSymbol(TypeFactory.java:732)
        at org.rascalmpl.types.TypeReifier.symbolToType(TypeReifier.java:206)
        at org.rascalmpl.values.RascalValueFactory.reifiedType(RascalValueFactory.java:389)
        at org.rascalmpl.types.TypeReifier.typeToValue(TypeReifier.java:63)
        at org.rascalmpl.semantics.dynamic.Expression$ReifyType.interpret(Expression.java:2376)
        at org.rascalmpl.semantics.dynamic.Expression$CallOrTree.interpret(Expression.java:502)
        at org.rascalmpl.semantics.dynamic.Declarator$Default.interpret(Declarator.java:52)
        at org.rascalmpl.semantics.dynamic.LocalVariableDeclaration$Default.interpret(LocalVariableDeclaration.java:36)
        at org.rascalmpl.semantics.dynamic.Statement$VariableDeclaration.interpret(Statement.java:1003)
        at org.rascalmpl.interpreter.result.RascalFunction.runBody(RascalFunction.java:385)
        at org.rascalmpl.interpreter.result.RascalFunction.call(RascalFunction.java:326)
        at org.rascalmpl.interpreter.result.AbstractPatternDispatchedFunction.call(AbstractPatternDispatchedFunction.java:186)
        at org.rascalmpl.interpreter.result.OverloadedFunction.callWith(OverloadedFunction.java:409)
        at org.rascalmpl.interpreter.result.OverloadedFunction.call(OverloadedFunction.java:369)
        at org.rascalmpl.semantics.dynamic.Expression$CallOrTree.interpret(Expression.java:540)
        at org.rascalmpl.semantics.dynamic.ListComprehensionWriter.append(ListComprehensionWriter.java:38)
        at org.rascalmpl.semantics.dynamic.Comprehension.evalComprehension(Comprehension.java:95)
        at org.rascalmpl.semantics.dynamic.Comprehension$List.interpret(Comprehension.java:39)
        at org.rascalmpl.semantics.dynamic.Expression$Comprehension.interpret(Expression.java:681)
        at org.rascalmpl.semantics.dynamic.Expression$CallOrTree.interpret(Expression.java:502)
        at org.rascalmpl.semantics.dynamic.Statement$Expression.interpret(Statement.java:365)
        at org.rascalmpl.semantics.dynamic.Statement$Return.interpret(Statement.java:782)
        at org.rascalmpl.semantics.dynamic.Statement$NonEmptyBlock.interpret(Statement.java:759)
        at org.rascalmpl.interpreter.utils.Cases.matchAndEval(Cases.java:443)
        at org.rascalmpl.interpreter.utils.Cases$DefaultBlock.matchAndEval(Cases.java:271)
        at org.rascalmpl.interpreter.utils.Cases$NodeCaseBlock.tryCases(Cases.java:406)
        at org.rascalmpl.interpreter.utils.Cases$NodeCaseBlock.matchAndEval(Cases.java:391)
        at org.rascalmpl.semantics.dynamic.Statement$Switch.interpret(Statement.java:898)
        at org.rascalmpl.interpreter.result.RascalFunction.runBody(RascalFunction.java:385)
        at org.rascalmpl.interpreter.result.RascalFunction.call(RascalFunction.java:326)
        at org.rascalmpl.interpreter.result.OverloadedFunction.callWith(OverloadedFunction.java:409)
        at org.rascalmpl.interpreter.result.OverloadedFunction.call(OverloadedFunction.java:369)
        at org.rascalmpl.semantics.dynamic.Expression$CallOrTree.interpret(Expression.java:540)
        at org.rascalmpl.semantics.dynamic.Statement$Expression.interpret(Statement.java:365)
        at org.rascalmpl.semantics.dynamic.Statement$Assignment.interpret(Statement.java:205)
        at org.rascalmpl.interpreter.result.RascalFunction.runBody(RascalFunction.java:385)
        at org.rascalmpl.interpreter.result.RascalFunction.call(RascalFunction.java:326)
        at org.rascalmpl.semantics.dynamic.Expression$CallOrTree.interpret(Expression.java:540)
        at org.rascalmpl.semantics.dynamic.Expression$Tuple.interpret(Expression.java:2776)
        at org.rascalmpl.semantics.dynamic.ListComprehensionWriter.append(ListComprehensionWriter.java:38)
        at org.rascalmpl.semantics.dynamic.Comprehension.evalComprehension(Comprehension.java:95)
        at org.rascalmpl.semantics.dynamic.Comprehension$List.interpret(Comprehension.java:39)
        at org.rascalmpl.semantics.dynamic.Expression$Comprehension.interpret(Expression.java:681)
        at org.rascalmpl.semantics.dynamic.Declarator$Default.interpret(Declarator.java:52)
        at org.rascalmpl.semantics.dynamic.LocalVariableDeclaration$Default.interpret(LocalVariableDeclaration.java:36)
        at org.rascalmpl.semantics.dynamic.Statement$VariableDeclaration.interpret(Statement.java:1003)
        at org.rascalmpl.interpreter.result.RascalFunction.runBody(RascalFunction.java:385)
        at org.rascalmpl.interpreter.result.RascalFunction.call(RascalFunction.java:326)
        at org.rascalmpl.semantics.dynamic.Expression$CallOrTree.interpret(Expression.java:540)
        at org.rascalmpl.semantics.dynamic.Statement$Expression.interpret(Statement.java:365)
        at org.rascalmpl.semantics.dynamic.Statement$Assignment.interpret(Statement.java:205)
        at org.rascalmpl.interpreter.result.RascalFunction.runBody(RascalFunction.java:385)
        at org.rascalmpl.interpreter.result.RascalFunction.call(RascalFunction.java:294)
        at org.rascalmpl.semantics.dynamic.Expression$CallOrTree.interpret(Expression.java:540)
        at org.rascalmpl.semantics.dynamic.Command$Expression.interpret(Command.java:61)
        at org.rascalmpl.interpreter.Evaluator.eval(Evaluator.java:1094)
        at org.rascalmpl.interpreter.Evaluator.eval(Evaluator.java:955)
        at org.rascalmpl.interpreter.Evaluator.eval(Evaluator.java:908)
        at org.rascalmpl.repl.RascalInterpreterREPL.evalStatement(RascalInterpreterREPL.java:132)
        at org.rascalmpl.vscode.lsp.terminal.LSPTerminalREPL$1.evalStatement(LSPTerminalREPL.java:136)
        at org.rascalmpl.repl.BaseRascalREPL.handleInput(BaseRascalREPL.java:106)
        at org.rascalmpl.vscode.lsp.terminal.LSPTerminalREPL$1.handleInput(LSPTerminalREPL.java:238)
        at org.rascalmpl.repl.BaseREPL.handleInput(BaseREPL.java:180)
        at org.rascalmpl.repl.BaseREPL.run(BaseREPL.java:347)
        at org.rascalmpl.vscode.lsp.terminal.LSPTerminalREPL.main(LSPTerminalREPL.java:320)

but when I hand written the output of the getScripts functions and pass that hard coded output as parameter the generatePTLAST works, why is it so? I assume it is an issue with Rascal but I might be wrong.


Solution

  • The error message is confusing because the internal error is not caught and rethrown as a user directed message. It means that rascal can not distinguish between two constructors and needs help disambiguating the definitions of the constructors.

    The code works manually probably because in the scope of the terminal repl the two offending constructors are not visible at the same time.

    In your module scope where the function is, there exist two definitions of the same data constructor named quoted identifier which are not distinguished by the types of the parameters.

    As @markhills wrote, this can be caused by reading in a binary version of the data which was written with a previous version of the datatype that used different names. It can also be caused by two different definitions sourced from two different imports. Etc.

    To fix, change the field name bank to the original name. Read the data. Change the name back to the new name, write the data again. Or, remove one of the duplicates, or make the name the same in both.