-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement record constructor typechecking
Summary: Very easy fix, but it should improve buck2 typechecking greatly. Reviewed By: JakobDegen Differential Revision: D64216008 fbshipit-source-id: 1477824b42bc8cb3da0ca745a11cad9ae5761a78
- Loading branch information
1 parent
616c7fc
commit dfdd63e
Showing
4 changed files
with
57 additions
and
5 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
21 changes: 21 additions & 0 deletions
21
starlark/src/values/types/record/record_type/record_callable_compile_time.golden
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,21 @@ | ||
# @generated | ||
# To regenerate, run: | ||
# ``` | ||
# STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib | ||
# ``` | ||
|
||
Program: | ||
|
||
Rec = record(a = int, b = str) | ||
|
||
def test(): | ||
Rec(c = []) | ||
|
||
Error: | ||
|
||
error: Unexpected parameter named `c` | ||
--> assert.bzl:4:9 | ||
| | ||
4 | Rec(c = []) | ||
| ^^^^^^ | ||
| |
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
21 changes: 21 additions & 0 deletions
21
starlark/src/values/types/record/ty_record_type/typecheck_record_type_call.golden
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,21 @@ | ||
# @generated | ||
# To regenerate, run: | ||
# ``` | ||
# STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib | ||
# ``` | ||
|
||
Program: | ||
|
||
MyRec = record(x = int) | ||
|
||
def test(): | ||
MyRec(x = "") | ||
|
||
Error: | ||
|
||
error: Expected type `int` but got `str` | ||
--> assert.bzl:4:11 | ||
| | ||
4 | MyRec(x = "") | ||
| ^^^^^^ | ||
| |