fix possible string error on inlined subroutines

This commit is contained in:
Irmen de Jong 2023-03-12 18:16:48 +01:00
parent 592f74124c
commit dc32318cec
2 changed files with 17 additions and 1 deletions

View File

@ -100,7 +100,9 @@ class UnusedCodeRemover(private val program: Program,
if(!subroutine.definingModule.isLibrary && !subroutine.hasBeenInlined) {
errors.warn("unused subroutine '${subroutine.name}'", subroutine.position)
}
program.removeInternedStringsFromRemovedSubroutine(subroutine)
if(!subroutine.inline) {
program.removeInternedStringsFromRemovedSubroutine(subroutine)
}
return listOf(IAstModification.Remove(subroutine, parent as IStatementContainer))
}
}

View File

@ -764,6 +764,20 @@ main {
sub start() {
sort(cards)
}
}"""
compileText(C64Target(), true, text, writeAssembly = false) shouldNotBe null
}
test("no string error when inlining") {
val text="""
main {
sub start() {
test()
}
sub test() {
cx16.r0 = "abc"
}
}"""
compileText(C64Target(), true, text, writeAssembly = false) shouldNotBe null
}