Skip to content

Instantly share code, notes, and snippets.

@gotwarlost
Last active October 15, 2023 23:17
Show Gist options
  • Save gotwarlost/ed094a6a93a6b9f7d3e58da5f8934616 to your computer and use it in GitHub Desktop.
Save gotwarlost/ed094a6a93a6b9f7d3e58da5f8934616 to your computer and use it in GitHub Desktop.

Works

$ cue def ./repro.cue | cue eval -H -
_request: [
            if _input.function != _|_ // explicit error (_|_ literal) in source
            {
        _input.function
    }, _input.test][0]
_input: {}

Fails

$ cue def ./repro.cue | cue fmt - | cue eval -H -
missing ',' in list literal:
    -:7:7
missing ',' before newline in list literal:
    -:9:3

The bad output

$ cue def ./repro.cue | cue fmt -
package repro

_request: [
		if _input.function != _|_ {
		_input.function
	} // explicit error (_|_ literal) in source, _input.test][0] ### <- here, the second list element is rendered after the comment
_input: {
	...
}
package repro
_request: [
if _input.function != _|_ {_input.function},
{_input.test},
][0]
_input: {...}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment