MVCoconut / coconut.data

Observable Data Layer.
The Unlicense
20 stars 8 forks source link

Having $last on multiple inner scopes leads to compile error #46

Closed Neverbirth closed 5 years ago

Neverbirth commented 5 years ago

I get a compile error when having something like this in a Model (code just written out of the top of my head, sorry):

class MyModel implements Model {
    @:loaded var somethingAmazing:Int = {
        if (incredibleProperty == 0) calculatePlanToConquerWorld($last);
        else if (incredibleProperty == 1) haveBreakfastBeforeConqueringTheWorld($last);
        else conquerWorld();
    };

    @:editable private var incredibleProperty:Int = -1;

    function calculatePlanToConquerWorld(whoKnows:Int) return Future.sync(1);
    function haveBreakfastBeforeConqueringTheWorld(whoKnows:Int) return Future.sync(2);
}

It seems both $lasts are replaced by the same variable that is generated in the same scope as whichever is processed first (assumption based just in the error message and that having a top level $last or single inner scope $last works).