Skip to content

Commit fc8f09f

Browse files
committed
WIP: Task: Matching enum value should be referenced statically
1 parent 5a33cc5 commit fc8f09f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/TypeSystem/Resolver/Match/MatchTypeResolver.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ private function resolveTypeOfEnumMatch(MatchNode $matchNode, EnumInstanceType $
109109
throw new \Error('@TODO Error: Cannot match enum with type of ' . $enumMemberType::class);
110110
}
111111

112+
if ($enumMemberType->isUnspecified()) {
113+
throw new \Error('@TODO Error: Matching enum value should be referenced statically');
114+
}
115+
112116
if (!$enumMemberType->enumStaticType->is($subjectEnumType->enumStaticType)) {
113117
throw new \Error('@TODO Error: incompatible enum match: got ' . $enumMemberType->enumStaticType->enumName . ' expected ' . $subjectEnumType->enumStaticType->enumName);
114118
}

test/Unit/TypeSystem/Resolver/Match/MatchTypeResolverTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ public function malformedEnumExamples(): iterable
191191
EOF,
192192
"@TODO Error: Cannot match enum with type of PackageFactory\ComponentEngine\TypeSystem\Type\StringType\StringType"
193193
];
194+
195+
yield "Matching enum value should be referenced statically" => [
196+
<<<'EOF'
197+
match (someEnumValue) {
198+
someEnumValue -> "a"
199+
}
200+
EOF,
201+
'@TODO Error: Matching enum value should be referenced statically'
202+
];
194203
}
195204

196205
/**

0 commit comments

Comments
 (0)