-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Need to add a few more. Reviewed By: JakobDegen Differential Revision: D64214360 fbshipit-source-id: 376156fe1e4076d8f0e7b2709465224ca5123856
- Loading branch information
1 parent
0765cd7
commit b3ce39f
Showing
9 changed files
with
166 additions
and
13 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
21 changes: 21 additions & 0 deletions
21
starlark/src/values/types/record/record_type/anon_record.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: | ||
|
||
record(a = field(int))(a = 1) | ||
|
||
Error: | ||
|
||
Traceback (most recent call last): | ||
* assert.bzl:1, in <module> | ||
record(a = field(int))(a = 1) | ||
error: Record instance cannot be created if record type is not assigned to a global variable | ||
--> assert.bzl:1:1 | ||
| | ||
1 | record(a = field(int))(a = 1) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| |
25 changes: 25 additions & 0 deletions
25
starlark/src/values/types/record/record_type/record_type_as_type_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,25 @@ | ||
# @generated | ||
# To regenerate, run: | ||
# ``` | ||
# STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib | ||
# ``` | ||
|
||
Program: | ||
|
||
RecFailCt1 = record(a = field(int), b = field(int)) | ||
RecFailCt2 = record(a = field(int), b = field(int)) | ||
|
||
def f_fail_ct(x: RecFailCt1): | ||
return x.a | ||
|
||
def test(): | ||
f_fail_ct(RecFailCt2(a = 1, b = 2)) | ||
|
||
Error: | ||
|
||
error: Expected type `RecFailCt1` but got `RecFailCt2` | ||
--> assert.bzl:8:15 | ||
| | ||
8 | f_fail_ct(RecFailCt2(a = 1, b = 2)) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| |
27 changes: 27 additions & 0 deletions
27
starlark/src/values/types/record/record_type/record_type_as_type_runtime.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,27 @@ | ||
# @generated | ||
# To regenerate, run: | ||
# ``` | ||
# STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib | ||
# ``` | ||
|
||
Program: | ||
|
||
RecFailRt1 = record(a = field(int), b = field(int)) | ||
RecFailRt2 = record(a = field(int), b = field(int)) | ||
|
||
def f_fail_rt(x: RecFailRt1): | ||
return x.a | ||
|
||
noop(f_fail_rt)(RecFailRt2(a = 1, b = 2)) | ||
|
||
Error: | ||
|
||
Traceback (most recent call last): | ||
* assert.bzl:7, in <module> | ||
noop(f_fail_rt)(RecFailRt2(a = 1, b = 2)) | ||
error: Value `record[RecFailRt2](a=1, b=2)` of type `record` does not match the type annotation `RecFailRt1` for argument `x` | ||
--> assert.bzl:7:1 | ||
| | ||
7 | noop(f_fail_rt)(RecFailRt2(a = 1, b = 2)) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| |
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
24 changes: 24 additions & 0 deletions
24
starlark/src/values/types/record/ty_record_type/fail_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,24 @@ | ||
# @generated | ||
# To regenerate, run: | ||
# ``` | ||
# STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib | ||
# ``` | ||
|
||
Program: | ||
|
||
MyRec = record(x = int) | ||
WrongRec = record(x = int) | ||
|
||
def foo(x: MyRec): pass | ||
|
||
def bar(): | ||
foo(WrongRec(x = 1)) | ||
|
||
Error: | ||
|
||
error: Expected type `MyRec` but got `WrongRec` | ||
--> assert.bzl:7:9 | ||
| | ||
7 | foo(WrongRec(x = 1)) | ||
| ^^^^^^^^^^^^^^^ | ||
| |
26 changes: 26 additions & 0 deletions
26
starlark/src/values/types/record/ty_record_type/fail_runtime_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,26 @@ | ||
# @generated | ||
# To regenerate, run: | ||
# ``` | ||
# STARLARK_RUST_REGENERATE_GOLDEN_TESTS=1 cargo test -p starlark --lib | ||
# ``` | ||
|
||
Program: | ||
|
||
MyRec = record(x = int) | ||
WrongRec = record(x = int) | ||
|
||
def foo(x: MyRec): pass | ||
|
||
noop(foo)(WrongRec(x = 1)) | ||
|
||
Error: | ||
|
||
Traceback (most recent call last): | ||
* assert.bzl:6, in <module> | ||
noop(foo)(WrongRec(x = 1)) | ||
error: Value `record[WrongRec](x=1)` of type `record` does not match the type annotation `MyRec` for argument `x` | ||
--> assert.bzl:6:1 | ||
| | ||
6 | noop(foo)(WrongRec(x = 1)) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| |
21 changes: 21 additions & 0 deletions
21
starlark/src/values/types/record/ty_record_type/typecheck_field_fail.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, y = int) | ||
|
||
def f(rec: MyRec) -> int: | ||
return rec.z | ||
|
||
Error: | ||
|
||
error: The attribute `z` is not available on the type `MyRec` | ||
--> assert.bzl:4:16 | ||
| | ||
4 | return rec.z | ||
| ^ | ||
| |