musictheory / NilScript

Objective-C-style language superset of JavaScript with a tiny, simple runtime
Other
50 stars 5 forks source link

@each codegen issue when iterating over ivar #41

Closed iccir closed 9 years ago

iccir commented 9 years ago

The following is failing to compile:

- (void) foo
{
    @each (var i in _ivar) {
        [i doSomething];
    }
}
iccir commented 9 years ago

Modifier issue.

Additional test cases:

- (void) foo
{
    @each (_iterator in _array) {
        [_iterator doSomething];
    }
}

- (void) foo
{
    var arr = [ 1, 2, 3 ];
    var sum = 0;
    @each (_iterator in arr) {
        sum += _iterator;
    }
    return sum;
}
iccir commented 9 years ago

It's going to be too hard (and probably not worth it) to support using an ivar as the storage for the iteration, and I can't really think of any case where this would be common.

Fixing the simple case (@each(var i in _array)) and making the compiler spit out an error in the additional cases (@each(_i in array)).