Skip to content

Fixing the typechecking rule for Optional + with ? #2650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
11 changes: 10 additions & 1 deletion dhall/src/Dhall/TypeCheck.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,12 +1314,21 @@ infer typer = loop

VOptional _O' -> do
case ks of
WithQuestion :| _ -> do

-- (Some x) with ? = v is valid iff the type of x is the same as the type of v.
WithQuestion :| [] -> do
tV' <- loop ctx v
if Eval.conv values _O' tV'
then return (VOptional _O')
else die OptionalWithTypeMismatch

-- (Some x) with ?.a.b = v is valid iff the type of x.a.b is the same as the type of v.
WithQuestion :| k₁ : ks' -> do
tV' <- with _O' (k₁ :| ks') v
if Eval.conv values _O' tV'
then return (VOptional _O')
else die OptionalWithTypeMismatch

WithLabel k :| _ -> die (NotAQuestionPath k)

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