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

yaml-to-dhall crashes (union in schema) #1074

Closed
vvv opened this issue Jul 5, 2019 · 2 comments · Fixed by #1083
Closed

yaml-to-dhall crashes (union in schema) #1074

vvv opened this issue Jul 5, 2019 · 2 comments · Fixed by #1083

Comments

@vvv
Copy link
Contributor

vvv commented Jul 5, 2019

yaml-to-dhall (and json-to-dhall) crashes if there is a union in schema:

$ dhall-to-yaml <<<'let U = < Foo | Bar : Text > in U.Foo'
Foo
$ echo Foo | yaml-to-dhall '< Foo | Bar : Text >'

Prelude.undefined
CallStack (from HasCallStack):
  error, called at libraries/base/GHC/Err.hs:78:14 in base:GHC.Err
  undefined, called at src/Dhall/JSONToDhall.hs:323:22 in dhall-json-1.3.0-3UOr6XfsCRnK61XKBZfXOr:Dhall.JSONToDhall

If unions are not supported by those utilities (which seems to be the case), they should explain this to the user and exit gracefully.

@Gabriella439
Copy link
Collaborator

Unions should be supported. I'll take a look at this soon to figure out what went wrong here

Gabriella439 added a commit that referenced this issue Jul 7, 2019
Fixes #1074

`dhall-to-{json,yaml}` treat empty alternatives as strings of the
same name, but `{json,yaml}-to-dhall` were missing the corresponding
logic to decode strings to empty alternatives, which this change
fixes.

This also ensures that the conversion logic contains no more
`undefined`s, by making the union conversion branch total.
@Gabriella439
Copy link
Collaborator

Fix is up here: #1083

@mergify mergify bot closed this as completed in #1083 Jul 8, 2019
mergify bot pushed a commit that referenced this issue Jul 8, 2019
* Handle empty alternatives when converting from JSON

Fixes #1074

`dhall-to-{json,yaml}` treat empty alternatives as strings of the
same name, but `{json,yaml}-to-dhall` were missing the corresponding
logic to decode strings to empty alternatives, which this change
fixes.

This also ensures that the conversion logic contains no more
`undefined`s, by making the union conversion branch total.

* Clarify successful cases for union handling

Co-Authored-By: Simon Jakobi <simon.jakobi@gmail.com>

* Add missing trailing newline

... as caught by @sjakobi
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 a pull request may close this issue.

2 participants