Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler crash when using call builtin #135

Closed
djehuti opened this issue Apr 30, 2024 · 6 comments
Closed

compiler crash when using call builtin #135

djehuti opened this issue Apr 30, 2024 · 6 comments

Comments

@djehuti
Copy link

djehuti commented Apr 30, 2024

The following PR exhibits the issue. When building the target repo with this PR:

* internal error *
Exception in thread "main" kotlin.UninitializedPropertyAccessException: lateinit property parent has not been initialized
        at prog8.code.ast.PtNode.getParent(AstBase.kt:15)
        at prog8.code.ast.PtNode.definingBlock(AstBase.kt:129)
        at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols$prefixSymbols(AsmGen.kt:59)
        at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols$prefixSymbols(AsmGen.kt:93)
        at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols$prefixSymbols(AsmGen.kt:93)
        at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols$prefixSymbols(AsmGen.kt:93)
        at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols$prefixSymbols(AsmGen.kt:93)
        at prog8.codegen.cpu6502.AsmGen6502.prefixSymbols(AsmGen.kt:98)
        at prog8.codegen.cpu6502.AsmGen6502.generate(AsmGen.kt:27)
        at prog8.compiler.CompilerKt.createAssemblyAndAssemble(Compiler.kt:496)
        at prog8.compiler.CompilerKt.compileProgram(Compiler.kt:147)
        at prog8.CompilerMainKt.compileMain(CompilerMain.kt:262)
        at prog8.CompilerMainKt.main(CompilerMain.kt:28)
make: *** [Makefile:30: hworld.prg] Error 1
@adiee5
Copy link
Contributor

adiee5 commented Apr 30, 2024

I think I know, what could cause it?

void = call(workFunc)

technically, the correct syntax for ignoring a return value from a single return value function is this:

void call(workFunc)

void = syntax wasn't a thing until multi-return syntax was added recently, and I guess the handling of void = for regular functions wasn't added, so stuff happen.

But that's just my thesis.

@djehuti
Copy link
Author

djehuti commented Apr 30, 2024

Yup, that fixes it. That's a fine workaround for me! (I'm used to that syntax.)

@djehuti
Copy link
Author

djehuti commented Apr 30, 2024

I'll let you ( @irmen ) decide whether to keep this open to handle that or just close it.

@adiee5
Copy link
Contributor

adiee5 commented Apr 30, 2024

yeah, let desertfish see it, so he can add a proper error message

@irmen
Copy link
Owner

irmen commented May 2, 2024

With -target virtual, it also crashes, but with a different error

Exception in thread "main" java.lang.IllegalArgumentException: node prog8.code.ast.PtFunctionCall@ccd1bc3 name is not scoped: call
at prog8.codegen.intermediate.IRCodeGen.verifyNameScoping$verifyPtNode(IRCodeGen.kt:65)
at prog8.codegen.intermediate.IRCodeGen.verifyNameScoping$verifyPtNode(IRCodeGen.kt:79)
at prog8.codegen.intermediate.IRCodeGen.verifyNameScoping$verifyPtNode(IRCodeGen.kt:79)
at prog8.codegen.intermediate.IRCodeGen.verifyNameScoping$verifyPtNode(IRCodeGen.kt:79)
at prog8.codegen.intermediate.IRCodeGen.verifyNameScoping(IRCodeGen.kt:90)
at prog8.codegen.intermediate.IRCodeGen.generate(IRCodeGen.kt:26)

@irmen
Copy link
Owner

irmen commented May 18, 2024

Minimal reproduction:

main {
  sub start() {
    void = call($2000)
  }
}

related compiler crash:

main {
  sub start() {
    void = 123
  }
}

@irmen irmen closed this as completed in 62afd33 May 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants