fix regression bug that left variables uninitialized

This commit is contained in:
Irmen de Jong 2021-05-01 01:35:03 +02:00
parent 0a5b30e21c
commit 19fe58dbac
2 changed files with 5 additions and 5 deletions

View File

@ -28,14 +28,14 @@ internal class VarConstantValueTypeAdjuster(private val program: Program, privat
errors.err(x.message, x.position)
}
// move a vardecl to the scope of the defining subroutine and put a regular assignment in its place here (if it has a value)
if(decl.type== VarDeclType.VAR && decl.datatype in NumericDatatypes) {
// move vardecl to the containing subroutine and add initialization assignment in its place if needed
if(decl.type == VarDeclType.VAR && decl.datatype in NumericDatatypes) {
val subroutine = decl.definingSubroutine() as? INameScope
if(subroutine!=null) {
if(subroutine!=null && subroutine!==parent) {
val declValue = decl.value
decl.value = null
decl.allowInitializeWithZero = false
return if(declValue==null) {
return if (declValue == null) {
listOf(
IAstModification.Remove(decl, parent as INameScope),
IAstModification.InsertFirst(decl, subroutine)

View File

@ -492,7 +492,7 @@ galaxy {
ubyte current_planet = planet.number
ubyte px = planet.x
ubyte py = planet.y
uword current_name = planet.name
uword current_name = &planet.name
ubyte pn = 0
uword scaling = 8
if local