-
-
Notifications
You must be signed in to change notification settings - Fork 670
Type checker does not detect a signature mismatch #2727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
Changqing-JING
added a commit
to Changqing-JING/assemblyscript
that referenced
this issue
Jul 29, 2023
class member function type is assigned to a normal function type
Changqing-JING
added a commit
to Changqing-JING/assemblyscript
that referenced
this issue
Jul 29, 2023
class member function type is assigned to a normal function type
CountBleck
added a commit
to CountBleck/assemblyscript
that referenced
this issue
Jul 31, 2023
In most cases, a function type is assignable to another if the target `this` parameter is a subtype of the original `this` parameter. However, this check wasn't performed correctly in `Signature#isAssignableTo`. Also, the reverse is true when checking whether override signatures are compatible, since the `this` parameter refers to the subclass that's overriding the parent class's method. At least, that's how I think it works... Fixes AssemblyScript#2727. Closes AssemblyScript#2728.
CountBleck
added a commit
to CountBleck/assemblyscript
that referenced
this issue
Jul 31, 2023
In most cases, a function type is assignable to another if the target `this` parameter is a subtype of the original `this` parameter. However, this check wasn't performed correctly in `Signature#isAssignableTo`. Also, the reverse is true when checking whether override signatures are compatible, since the `this` parameter refers to the subclass that's overriding the parent class's method. At least, that's how I think it works... Fixes AssemblyScript#2727. Closes AssemblyScript#2728.
CountBleck
added a commit
to CountBleck/assemblyscript
that referenced
this issue
Jul 31, 2023
In most cases, a function type is assignable to another if the target `this` parameter is a subtype of the original `this` parameter. However, this check wasn't performed correctly in `Signature#isAssignableTo`. Also, the reverse is true when checking whether override signatures are compatible, since the `this` parameter refers to the subclass that's overriding the parent class's method. At least, that's how I think it works... Fixes AssemblyScript#2727. Closes AssemblyScript#2728.
HerrCai0907
pushed a commit
that referenced
this issue
Oct 1, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug description
Consider the source code below. The function
expectCallback
needs another function as its argument to produce a number. If we usecallback
this works as expected.However, if (by mistake) we use a method we'd expect the compiler to detect a signature mismatch because methods implicitly have an extra
this
parameter. This is not detected. The code below compiles without issues.Only during runtime we see the expected problem:
Steps to reproduce
AssemblyScript version
0.27.5
The text was updated successfully, but these errors were encountered: