Skip to content

Commit

Permalink
add test case for case types which used to not terminate
Browse files Browse the repository at this point in the history
Summary: It now terminates I believe Scott's recent diff D62504808, so committing as regression test

Reviewed By: madgen

Differential Revision: D62646799

fbshipit-source-id: 29560a02845ca3a69df2b61075cb8de84a9159ad
  • Loading branch information
Catherine Gasnier authored and facebook-github-bot committed Sep 16, 2024
1 parent 96c1e28 commit b223a72
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 28 deletions.
91 changes: 63 additions & 28 deletions hphp/hack/src/typing/dune
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@
(library
(name typing_class_types)
(wrapped false)
(modules typing_class_types)
(modules
typing_class_types)
(libraries
collections
decl_defs
Expand All @@ -139,7 +140,8 @@
(library
(name folded_class)
(wrapped false)
(modules folded_class)
(modules
folded_class)
(libraries
core_kernel
decl
Expand Down Expand Up @@ -168,7 +170,10 @@
(library
(name nast_visitor)
(wrapped false)
(modules nast_check_env nast_visitor stateful_aast_visitor )
(modules
nast_check_env
nast_visitor
stateful_aast_visitor)
(libraries nast provider_context naming_attributes_params)
(preprocess
(pps ppx_deriving.std)))
Expand Down Expand Up @@ -208,22 +213,25 @@
(library
(name tast_type_collector)
(wrapped false)
(modules tast_type_collector)
(modules
tast_type_collector)
(libraries core_kernel full_fidelity tast_env)
(preprocess
(pps ppx_deriving.std)))

(library
(name typing_modules)
(wrapped false)
(modules typing_modules)
(libraries typing_env typing_env_types decl_provider))
(name typing_modules)
(wrapped false)
(modules
typing_modules)
(libraries typing_env typing_env_types decl_provider))

(library
(name typing_packages)
(wrapped false)
(modules typing_packages)
(libraries typing_env typing_env_types))
(name typing_packages)
(wrapped false)
(modules
typing_packages)
(libraries typing_env typing_env_types))

(library
(name typing)
Expand Down Expand Up @@ -278,7 +286,8 @@
(library
(name typing_skeleton)
(wrapped false)
(modules typing_skeleton)
(modules
typing_skeleton)
(libraries typing_defs)
(preprocess
(pps ppx_deriving.std)))
Expand Down Expand Up @@ -308,23 +317,37 @@
typing_requirements
typing_subtype_method
typing_type_wellformedness)
(libraries typing_algebra typing_common typing_modules typing_packages typing_skeleton)
(libraries
typing_algebra
typing_common
typing_modules
typing_packages
typing_skeleton)
(preprocess
(pps ppx_deriving.std)))

(library
(name type_mapper_generic)
(wrapped false)
(modules type_mapper_generic)
(libraries common core_kernel typing_defs)
(modules
type_mapper_generic)
(libraries
common
core_kernel
typing_defs)
(preprocess
(pps ppx_deriving.std)))

(library
(name type_mapper_forget)
(wrapped false)
(modules type_mapper_forget)
(libraries common core_kernel type_mapper_generic typing_defs)
(modules
type_mapper_forget)
(libraries
common
core_kernel
type_mapper_generic
typing_defs)
(preprocess
(pps ppx_deriving.std)))

Expand Down Expand Up @@ -377,23 +400,29 @@
(library
(name typing_visibility)
(wrapped false)
(modules typing_visibility)
(libraries typing_modules typing_packages typing_utils)
(modules
typing_visibility)
(libraries
typing_modules
typing_packages
typing_utils)
(preprocess
(pps ppx_deriving.std)))

(library
(name typing_disposable)
(wrapped false)
(modules typing_disposable)
(modules
typing_disposable)
(libraries typing_utils typing_error_utils)
(preprocess
(pps ppx_deriving.std)))

(library
(name typing_dependent_type)
(wrapped false)
(modules typing_dependent_type)
(modules
typing_dependent_type)
(libraries typing_utils)
(preprocess
(pps ppx_deriving.std)))
Expand All @@ -409,23 +438,26 @@
(library
(name type_mapper)
(wrapped false)
(modules type_mapper)
(modules
type_mapper)
(libraries typing_env)
(preprocess
(pps ppx_deriving.std)))

(library
(name typing_print)
(wrapped false)
(modules typing_print)
(modules
typing_print)
(libraries decl_provider hackfmt typing_logic typing_env_types)
(preprocess
(pps ppx_deriving.std)))

(library
(name typing_log)
(wrapped false)
(modules typing_log )
(modules
typing_log)
(libraries decl_provider hackfmt typing_logic typing_env_types typing_print)
(preprocess
(pps ppx_deriving.std)))
Expand Down Expand Up @@ -490,7 +522,8 @@
(library
(name typing_check_job)
(wrapped false)
(modules typing_check_job)
(modules
typing_check_job)
(libraries
core_kernel
deferred_decl
Expand All @@ -507,7 +540,8 @@
(library
(name typing_check)
(wrapped false)
(modules typing_check_service)
(modules
typing_check_service)
(libraries
biglist
cgroupprofiler
Expand Down Expand Up @@ -541,7 +575,8 @@
(library
(name hh_distc_types)
(wrapped false)
(modules hh_distc_types)
(modules
hh_distc_types)
(libraries errors)
(preprocess
(pps ppx_deriving.std)))
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?hh
<<file: __EnableUnstableFeatures('case_types')>>

case type A as A = A;

function expect_A(A $_): void {}
function expect_string(string $_): void {}

function foo(A $a, string $s): void {
expect_A($a);
expect_string($a); // nok: A <: string -> A <: string -> recursing -> nok
expect_A($s); // nok: string <: A -> string <: A -> recursing -> nok
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ERROR: File "subtyping_simple1b.php", line 4, characters 11-11:
Cyclic type definition (Typing[4014])
File "subtyping_simple1b.php", line 4, characters 20-20:
Cyclic use is here
ERROR: File "subtyping_simple1b.php", line 11, characters 17-18:
Invalid argument (Typing[4110])
File "subtyping_simple1b.php", line 7, characters 24-29:
Expected `string`
File "subtyping_simple1b.php", line 4, characters 16-16:
But got `mixed`
ERROR: File "subtyping_simple1b.php", line 12, characters 12-13:
Invalid argument (Typing[4110])
File "subtyping_simple1b.php", line 6, characters 19-19:
Expected `A`
File "subtyping_simple1b.php", line 9, characters 20-25:
But got `string`
ERROR: File "subtyping_simple1b.php", line 4, characters 11-11:
Invalid constraint on `newtype` (Typing[4332])
File "subtyping_simple1b.php", line 4, characters 16-16:
Expected `A`
File "subtyping_simple1b.php", line 4, characters 20-20:
But got `mixed`
ERROR: File "subtyping_simple1b.php", line 4, characters 11-11:
Invalid constraint on `newtype` (Typing[4332])
File "subtyping_simple1b.php", line 4, characters 16-16:
Expected `A`
File "subtyping_simple1b.php", line 4, characters 20-20:
But got `nonnull`

0 comments on commit b223a72

Please sign in to comment.