microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
721 stars 590 forks source link

Assertion error building extension with C++ shim with more than 4 parameters #4951

Closed adamish closed 1 year ago

adamish commented 1 year ago

Describe the bug If you call a shim method with more than 4 parameters you get an assertion error. I cannot seem to find this documented.

To Reproduce

main.ts

/**
 */
//%
namespace foons {
    /**
     */
    //% shim=foons::fooNative
    export function foo(a : Number, b : Number, c : Number, d : Number, e : Number): void {
        console.log("test")
    }
}
foons.foo(1, 2, 3, 4, 5);

foo.cpp

namespace foons {
    /**
     *
     */
    //%
    void fooNative(int a, int b, int c, int d, int e) {
    }
}

Actual behaviour

main.ts(1,1): error TS9200: Assertion failed

Expected behaviour

PXT microbit 5.1.2

Desktop (please complete the following information):

Additional context Note same code works if you change to use 4 parameters (remove e from both typescript and .cpp)

abchatra commented 1 year ago

@mmoskal by design constraint right?

mmoskal commented 1 year ago

Yes, ARM calling convention changes when there is more than 4 arguments and the current code generator doesn't support this.

abchatra commented 1 year ago

Can't fix without lot of compiler changes. Sorry!