diff --git a/compiler/src/prog8/compiler/astprocessing/LiteralsToAutoVars.kt b/compiler/src/prog8/compiler/astprocessing/LiteralsToAutoVars.kt index 63fbc6d4f..9f750252f 100644 --- a/compiler/src/prog8/compiler/astprocessing/LiteralsToAutoVars.kt +++ b/compiler/src/prog8/compiler/astprocessing/LiteralsToAutoVars.kt @@ -74,6 +74,13 @@ internal class LiteralsToAutoVars(private val program: Program, private val erro override fun after(decl: VarDecl, parent: Node): Iterable { 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) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 82b309640..0c203eb06 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,8 +1,6 @@ TODO ==== -can we make ubyte x,y = cbm.SCREEN() work? (sugar for ubyte x,y // x,y=cbm.SCREEN() ?) - ... diff --git a/examples/test.p8 b/examples/test.p8 index 14c91279c..57f38aa19 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -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 + }} } }