Skip to content

Commit

Permalink
Test for record constructor is not typechecked
Browse files Browse the repository at this point in the history
Summary: Adding a test for bootcamper to know what to fix.

Reviewed By: JakobDegen

Differential Revision: D55549122

fbshipit-source-id: 2f09c6c45e24a629506e435168009d9ece55d1a3
  • Loading branch information
stepancheg authored and facebook-github-bot committed Mar 30, 2024
1 parent 4ec074b commit 48fea1d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion starlark/src/values/types/record/record_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ where
TypeInstanceId::gen(),
TyUserParams {
callable: Some(TyCallable::new(
// TODO(nga): more precise parameter types.
// TODO(nga): more precise parameter types
// https://www.internalfb.com/tasks/?t=184025179
ParamSpec::new(vec![Param::kwargs(Ty::any())]),
ty_record.dupe(),
)),
Expand Down
13 changes: 13 additions & 0 deletions starlark/src/values/types/record/ty_record_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,17 @@ def f(rec: MyRec) -> int:
r#"The attribute `z` is not available on the type `MyRec`"#,
);
}

#[test]
fn test_typecheck_record_type_call() {
// TODO(nga): this should fail.
assert::pass(
r#"
MyRec = record(x = int)
def test():
MyRec(x = "")
"#,
);
}
}

0 comments on commit 48fea1d

Please sign in to comment.