Skip to content

Commit 3ff4166

Browse files
authored
Fixing the typechecking rule for Optional + with ? (#2650)
* Fixing the typesetting rule * remove extraneous comment and refactor * Revert "remove extraneous comment and refactor" This reverts commit 215d4d1. * revert refactor as it fails * bump ci * bump ci * bump ci * bump ci
1 parent 2d8a397 commit 3ff4166

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

dhall/src/Dhall/TypeCheck.hs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,12 +1314,21 @@ infer typer = loop
13141314

13151315
VOptional _O' -> do
13161316
case ks of
1317-
WithQuestion :| _ -> do
1317+
1318+
-- (Some x) with ? = v is valid iff the type of x is the same as the type of v.
1319+
WithQuestion :| [] -> do
13181320
tV' <- loop ctx v
13191321
if Eval.conv values _O' tV'
13201322
then return (VOptional _O')
13211323
else die OptionalWithTypeMismatch
13221324

1325+
-- (Some x) with ?.a.b = v is valid iff the type of x.a.b is the same as the type of v.
1326+
WithQuestion :| k₁ : ks' -> do
1327+
tV' <- with _O' (k₁ :| ks') v
1328+
if Eval.conv values _O' tV'
1329+
then return (VOptional _O')
1330+
else die OptionalWithTypeMismatch
1331+
13231332
WithLabel k :| _ -> die (NotAQuestionPath k)
13241333

13251334
_ -> die (NotWithARecord e₀ (quote names tE')) -- TODO: NotWithARecordOrOptional

0 commit comments

Comments
 (0)