Skip to content

misleading compiler error #1699

Closed
Closed
@petersalomonsen

Description

@petersalomonsen

See the output from my travis build using the latest AssemblyScript 0.18.11 ( upgrading from 0.17.7 )

https://travis-ci.com/github/petersalomonsen/javascriptmusic/jobs/485666265#L267

ERROR TS2469: The '++' operator cannot be applied to type 'assembly/midi/midisynth/MidiVoice'.
       for (let n=0; n < numActiveVoices; n++) {
                                          ~~~

I would expect that n is interpreted as type i32 and not as MidiVoice.

The exact same code pass in AssemblyScript 0.17.7.

Also tested with 0.17.13 and 0.18.0, and found that the error was introduced in 0.18.0


Test case for reproducing:

class Foo {

}

function test(): void {
    const foos = new Array<Foo>(1);
    foos[0] = foos[0] = new Foo();

    for (let n = 0; n < foos.length; n++) {
        const v = foos[n];
    }
}

test();

The error is actually caused by a mistake in my code in the line foos[0] = foos[0] = new Foo(); which should have been foos[0] = new Foo();. However the compile error message is misleading, and is not really a compile error.

I'll look into this myself later on, but just wanted to file the issue in case anyone else get an instant idea of what it might be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions