This repository was archived by the owner on Sep 1, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Expand file tree Collapse file tree 2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ final class ShapeSpec extends TypeSpec<shape()> {
6767
6868 <<__Override >>
6969 public function assertType (mixed $value ): shape() {
70- if (! \HH \ is_dict_or_darray ($value )) {
70+ if (! ( \HH \ is_php_array ($value ) || ( $value is dict < _ , _ > ) )) {
7171 throw IncorrectTypeException :: withValue(
7272 $this -> getTrace(),
7373 ' shape' ,
@@ -80,9 +80,7 @@ final class ShapeSpec extends TypeSpec<shape()> {
8080 foreach ($this -> inners as $key => $spec ) {
8181 $trace = $this -> getTrace()-> withFrame(' shape[' . $key . ' ]' );
8282 if (C \contains_key ($value , $key )) {
83- // Using idx() even though we just checked the key's existence, to avoid
84- // a Hack error.
85- $out [$key ] = $spec -> withTrace($trace )-> assertType(idx ($value , $key ));
83+ $out [$key ] = $spec -> withTrace($trace )-> assertType($value [$key ] ?? null );
8684 continue ;
8785 }
8886
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ final class TupleSpec extends TypeSpec<BogusTuple> {
2222
2323 <<__Override >>
2424 public function coerceType (mixed $value ): BogusTuple {
25- if (! \HH \ is_vec_or_varray ($value )) {
25+ if (! ( \HH \ is_php_array ($value ) || ( $value is vec < _ > ) )) {
2626 throw
2727 TypeCoercionException :: withValue($this -> getTrace(), ' tuple' , $value );
2828 }
@@ -49,13 +49,12 @@ final class TupleSpec extends TypeSpec<BogusTuple> {
4949
5050 <<__Override >>
5151 public function assertType (mixed $value ): BogusTuple {
52- if (! \HH \ is_vec_or_varray ($value )) {
52+ if (\HH \ is_php_array ($value )) {
53+ $value = vec ($value );
54+ } else if (! ($value is vec < _ > )) {
5355 throw
5456 IncorrectTypeException :: withValue($this -> getTrace(), ' tuple' , $value );
5557 }
56- if (! $value is vec < _ > ) {
57- $value = vec ($value );
58- }
5958 $values = $value ;
6059
6160 $count = \count ($values );
You can’t perform that action at this time.
0 commit comments