-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: function: do not mistake optional argument for vararg
Fixes #826.
- Loading branch information
Showing
3 changed files
with
31 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
local util = require("spec.util") | ||
|
||
describe("subtyping of functions:", function() | ||
it("f(a, ?b) <: f(a) (regression test 1 for #826)", util.check([[ | ||
local type shared = string | ||
local interface test1 | ||
a: function(a:string,b:shared) | ||
end | ||
local record test2 is test1 | ||
a: function(a:string, b:shared, c?:string) -- Error when shared != string | ||
end | ||
local record test3 is test1 | ||
a: function(a:string, b:shared, c?:number) -- Error when shared != number | ||
end | ||
]])) | ||
|
||
it("f(a, ?b) <: f(a) (regression test 2 for #826)", util.check([[ | ||
local type shared = number | ||
local interface test1 | ||
a: function(a:string,b:shared) | ||
end | ||
local record test2 is test1 | ||
a: function(a:string, b:shared, c?:string) -- Error when shared != string | ||
end | ||
local record test3 is test1 | ||
a: function(a:string, b:shared, c?:number) -- Error when shared != number | ||
end | ||
]])) | ||
end) |
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