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

cmd/cue: trim bug when using disjunction of embeded definitions? #1298

Open
joulaud opened this issue Oct 13, 2021 · 3 comments
Open

cmd/cue: trim bug when using disjunction of embeded definitions? #1298

joulaud opened this issue Oct 13, 2021 · 3 comments
Labels
NeedsFix trim This issue is related to trim.
Milestone

Comments

@joulaud
Copy link

joulaud commented Oct 13, 2021

What version of CUE are you using (cue version)?

$ cue version
cue version 0.4.0 linux/amd64

Does this issue reproduce with the latest release?

What did you do?

$ cat <<'EOF' >x.cue
#DefA: A: "a"
#DefB: B: "b"

First: {
        #DefA | #DefB
        C: "c"
}

First: {
        B: "b"
        C: "c"
}
EOF


$ cue trim x.cue
  {
      #DefA: {
        A: "a"
      }
      #DefB: {
        B: "b"
      }
-     First: {
-       B: "b"
-       C: "c"
-     }
+     First: {
+       C: "c"
+       A: "a"
+     } | {
+       C: "c"
+       B: "b"
+     }
  }
Aborting trim, output differs after trimming. This is a bug! Use -i to force trim.
You can file a bug here: https://github.com/cuelang/cue/issues/new?assignees=&labels=NeedsInvestigation&template=bug_report.md&title=

What did you expect to see?

No error, and trimming of line 11 C: "c"

What did you see instead?

Bug detection by cue trim as described above.

@joulaud joulaud added NeedsInvestigation Triage Requires triage/attention labels Oct 13, 2021
@joulaud joulaud changed the title output differs after trimming ¿when using disjunction of embeded definitions? cue trim bug ¿when using disjunction of embeded definitions? Oct 19, 2021
@mpvl mpvl added NeedsFix trim This issue is related to trim. and removed NeedsInvestigation Triage Requires triage/attention labels Oct 26, 2021
@mpvl mpvl added this to the v0.4.x milestone Oct 26, 2021
@mpvl
Copy link
Member

mpvl commented Oct 26, 2021

The faulty trim is caused by the removal of B: "b" in the second First. This is related to another outstanding trim bug.

Note however, that, with the current interpretation of trim, C: "c" cannot be removed, as it would not know which of the two instances of C: "c" should be removed as one does not "dominate" the other.

@myitcv myitcv changed the title cue trim bug ¿when using disjunction of embeded definitions? cmd/cue: trim bug when using disjunction of embeded definitions? Nov 19, 2021
@mpvl
Copy link
Member

mpvl commented Feb 4, 2022

To be more precise on what is going on: evaluation eliminates one of the disjunctions. Trim proceeds with the evaluated value as if it weren't evaluated from a disjunction. It then removes the very field that was used to disambiguate the disjunction. After this removal, the disjunction no longer disambiguates.

@myitcv
Copy link
Member

myitcv commented Apr 27, 2023

Dropping the now meaningless v0.4.x milestone. We have relabelled this from trim to roadmap/trim to indicate that a fix for this issue (and indeed all trim issues) requires a more substantial piece of work.

@myitcv myitcv modified the milestones: v0.4.x, trim-redesign Apr 27, 2023
@myitcv myitcv added zGarden and removed zGarden labels Jun 13, 2023
@mvdan mvdan removed the zGarden label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix trim This issue is related to trim.
Projects
None yet
Development

No branches or pull requests

4 participants