Skip to content

frontend: Crash when wrongly using Ex model invocation where an identifier is expected #920

@AndreasKrall

Description

@AndreasKrall

The following minimal wrong specification produces a crash instead of an error message. To happen it is necessary to wrap a model-type in a record definition which gives an Ex where an identifier is expected:

model-type exType = ()-> Ex

record wrap (funct: exType)

model exId () : Ex = {add}  // correct with type Id, is instantiated to an identifier but we do not have macro type casts

model genConstant (w : wrap) : Defs = {
  constant test = VADL::$w.funct() (3, 4)
}

$genConstant ((exId))

Crash result:

nativevadl check fehler.vadl
                             ___ ___    _   ___ _  _
                            / __| _ \  /_\ / __| || |
                           | (__|   / / _ \\__ \ __ |
                            \___|_|_\/_/ \_\___/_||_|

                       🔥 The OpenVADL compiler crashed 🔥

This shouldn't have happened, please open an issue with the stacktrace below at:
https://github.com/OpenVADL/open-vadl/issues/new


java.lang.ClassCastException: vadl.ast.GroupedExpr cannot be cast to vadl.ast.IdentifierOrPlaceholder
	at vadl.ast.IdentifierPath.prettyPrintExpr(Expr.java:1592)
	at vadl.ast.Expr.prettyPrint(Expr.java:87)
	at vadl.ast.IdentifierPath.pathToString(Expr.java:1573)
	at vadl.ast.IdentifierPath.pathToSegments(Expr.java:1586)
	at vadl.ast.SymbolTable.resolve(SymbolTable.java:223)
	at vadl.ast.SymbolTable$SymbolResolver.visit(SymbolTable.java:913)
	at vadl.ast.SymbolTable$SymbolResolver.visit(SymbolTable.java:885)
	at vadl.ast.IdentifierPath.accept(Expr.java:1603)
	at vadl.ast.RecursiveAstVisitor.travel(AstVisitor.java:53)
	at java.base@25.0.2/java.lang.Iterable.forEach(Iterable.java:75)
	at vadl.ast.RecursiveAstVisitor.visit(AstVisitor.java:696)
	at vadl.ast.RecursiveAstVisitor.visit(AstVisitor.java:31)
	at vadl.ast.CallIndexExpr.accept(Expr.java:1893)
	at vadl.ast.RecursiveAstVisitor.travel(AstVisitor.java:53)
	at java.base@25.0.2/java.util.ArrayList.forEach(ArrayList.java:1604)
	at vadl.ast.RecursiveAstVisitor.visit(AstVisitor.java:192)
	at vadl.ast.RecursiveAstVisitor.visit(AstVisitor.java:31)
	at vadl.ast.ConstantDefinition.accept(Definition.java:372)
	at vadl.ast.SymbolTable$SymbolResolver.resolveSymbols(SymbolTable.java:890)
	at vadl.ast.SymbolTable.lambda$collectAndResolveSymbols$0(SymbolTable.java:549)
	at vadl.ast.InterleavedTimingRecorder.withPassTiming(InterleavedTimingRecorder.java:120)
	at vadl.ast.SymbolTable.collectAndResolveSymbols(SymbolTable.java:547)
	at vadl.ast.VadlParser.parse(VadlParser.java:124)
	at vadl.ast.VadlParser.lambda$parse$1(VadlParser.java:95)
	at vadl.ast.InterleavedTimingRecorder.withPassTiming(InterleavedTimingRecorder.java:120)
	at vadl.ast.Ast.withPassTiming(Ast.java:54)
	at vadl.ast.VadlParser.parse(VadlParser.java:95)
	at vadl.cli.BaseCommand.parseToAst(BaseCommand.java:189)
	at vadl.cli.BaseCommand.parseToVIAM(BaseCommand.java:266)
	at vadl.cli.BaseCommand.call(BaseCommand.java:405)
	at vadl.cli.BaseCommand.call(BaseCommand.java:69)
	at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
	at picocli.CommandLine.access$1500(CommandLine.java:148)
	at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
	at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
	at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
	at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
	at picocli.CommandLine.execute(CommandLine.java:2174)
	at vadl.cli.Main.main(Main.java:45)
	at java.base@25.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfrontendThis is frontend related

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions