mirror of
https://github.com/irmen/prog8.git
synced 2025-03-14 11:34:32 +00:00
fix compiler crash when initializing struct var with something other than a struct literal
This commit is contained in:
parent
f265199fbe
commit
511b47bac4
@ -82,6 +82,11 @@ internal class AstIdentifiersChecker(private val program: Program,
|
||||
return super.visit(decl)
|
||||
}
|
||||
|
||||
if(decl.value !is StructLiteralValue) {
|
||||
errors.err("requires struct literal value to initialize a struct variable", decl.value?.position ?: decl.position)
|
||||
return super.visit(decl)
|
||||
}
|
||||
|
||||
val decls = decl.flattenStructMembers()
|
||||
decls.add(decl)
|
||||
val result = AnonymousScope(decls, decl.position)
|
||||
|
@ -118,8 +118,8 @@ internal class AssignmentAsmGen(private val program: Program, private val asmgen
|
||||
assignFromEvalResult(assign.target)
|
||||
}
|
||||
is ArrayLiteralValue, is StringLiteralValue -> TODO("string/array/struct assignment?")
|
||||
is StructLiteralValue -> throw AssemblyError("struct literal value assignment should have been flattened")
|
||||
is RangeExpr -> throw AssemblyError("range expression should have been changed into array values")
|
||||
is StructLiteralValue -> throw AssemblyError("struct literal value assignment should have been flattened ${assign.value.position}")
|
||||
is RangeExpr -> throw AssemblyError("range expression should have been changed into array values ${assign.value.position}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,8 @@ main {
|
||||
}
|
||||
|
||||
sub start() {
|
||||
; Color c = [1,2,3] ; TODO fix compiler error
|
||||
Color c = {1,2,3}
|
||||
c= {1,2,3}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user