-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/remove pcall method warning (#668)
Fixes #656. ### What? - Adds tests for the incorrect warnings and errors raised in #656 - Updates `special_pcall_xpcall` so that the function type of the first argument is treated as not a method, even if it is a method ### Why? Resolves #656 `pcall` (and `xpcall`) invokes its first argument as a regular function with the provided arguments - it has no way of implicitly passing the `self` parameter from the method owner of its first argument to the method. Therefore, it should not warn `invoked method as a regular function: use ':' instead of '.'` when its first argument is a method, or raise this as the error message when passed an argument of incorrect type. ### Anything else? I was slightly worried that setting `is_method` to `false` on this type might cause unintended side-effects, however I have checked through the sequence of function calls from `special_pcall_xpcall` where `ftype` is passed, and it appears that `is_method` is exclusively used for determining whether to show these warnings / errors. Squashed commits: * feat(spec): adds tests to pcall_spec and xpcall_spec for method call warnings * feat(spec): adds additional tests to pcall_spec and xpcall_spec for method call errors * fix: sets is_method to false for the function type passed to pcall or xpcall * chore: adds modified tl.lua from previous commit * chore: clarifies comment
- Loading branch information
1 parent
cc96c76
commit 8829655
Showing
4 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters