Skip to content
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

Check for duplicate record type field names #10

Merged
merged 2 commits into from
Apr 14, 2020
Merged

Check for duplicate record type field names #10

merged 2 commits into from
Apr 14, 2020

Conversation

travisbrown
Copy link
Owner

Fixes #6:

scala> import org.dhallj.syntax._
import org.dhallj.syntax._

scala> val Left(failure) = "{x: Natural, x: Natural}".parseExpr.flatMap(_.typeCheck)
failure: org.dhallj.core.DhallException = org.dhallj.core.typechecking.TypeCheckFailure: duplicate field: x

We follow the Haskell implementation in failing fast on duplicate field names even if there are invalid type errors:

scala> val Left(failure) = "{x: Natural, x: 0}".parseExpr.flatMap(_.typeCheck)
failure: org.dhallj.core.DhallException = org.dhallj.core.typechecking.TypeCheckFailure: duplicate field: x

Compare:

$ dhall --explain <<< "{x: Natural, x: 0}"
dhall: 
Error: Invalid input

(stdin):1:18:
  |
1 | {x: Natural, x: 0}
  |                  ^
duplicate field: x

@travisbrown travisbrown merged commit 79d2961 into master Apr 14, 2020
@travisbrown travisbrown deleted the fix/6 branch April 14, 2020 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decide what to do about type checker failure test failure
1 participant