mirror of
https://github.com/irmen/prog8.git
synced 2025-01-11 13:29:45 +00:00
better error message for ambiguous multi-var initialization in vardecl
This commit is contained in:
parent
f88c29e083
commit
19ebc6d6b3
@ -74,6 +74,13 @@ internal class LiteralsToAutoVars(private val program: Program, private val erro
|
||||
|
||||
override fun after(decl: VarDecl, parent: Node): Iterable<IAstModification> {
|
||||
if(decl.names.size>1) {
|
||||
|
||||
val fcallTarget = (decl.value as? IFunctionCall)?.target?.targetSubroutine(program)
|
||||
if(fcallTarget!=null && fcallTarget.returntypes.size>1) {
|
||||
errors.err("ambiguous multi-variable initialization. Use separate variable declaration and assignment(s) instead.", decl.value!!.position)
|
||||
return noModifications
|
||||
}
|
||||
|
||||
// note: the desugaring of a multi-variable vardecl has to be done here
|
||||
// and not in CodeDesugarer, that one is too late (identifiers can't be found otherwise)
|
||||
if(decl.datatype !in NumericDatatypesWithBoolean)
|
||||
|
@ -1,8 +1,6 @@
|
||||
TODO
|
||||
====
|
||||
|
||||
can we make ubyte x,y = cbm.SCREEN() work? (sugar for ubyte x,y // x,y=cbm.SCREEN() ?)
|
||||
|
||||
...
|
||||
|
||||
|
||||
|
@ -4,8 +4,12 @@
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
ubyte @shared x,y,z
|
||||
ubyte @shared k,l,m = 42
|
||||
uword @shared r,s,t = sys.progend()
|
||||
ubyte @shared x,y = multi()
|
||||
}
|
||||
|
||||
asmsub multi() -> ubyte @A, ubyte @Y {
|
||||
%asm {{
|
||||
rts
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user