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

language: support optional markers for dynamic fields #2107

Closed
disintegrator opened this issue Nov 17, 2022 · 10 comments
Closed

language: support optional markers for dynamic fields #2107

disintegrator opened this issue Nov 17, 2022 · 10 comments
Labels
FeatureRequest New feature or request

Comments

@disintegrator
Copy link

disintegrator commented Nov 17, 2022

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

$ cue version
cue version v0.4.3 darwin/arm64

Does this issue reproduce with the latest release?

Yes

What did you do?

https://cuelang.org/play/?id=QTJz8OOP282#cue@export@cue

#Geos: ["UK", "AU"]
#PerGeo: {
  _value: _

  for _, geo in #Geos {
    (geo)?: _value
  }
}

out: #PerGeo & { _value: >= 0.0 }

What did you expect to see?

I was expecting to get the same output as the following: https://cuelang.org/play/?id=U2gP5VJNJS-#cue@export@cue

out: {}

or more accurately

What did you see instead?

The fields that resulted from the comprehension were not marked as optional. The optional marker was ignored and I got the following:

out: {
	UK: >=0.0
	AU: >=0.0
}

Keywords: string interpolation, field name expression, optional fields, structs

@disintegrator disintegrator added NeedsInvestigation Triage Requires triage/attention labels Nov 17, 2022
@disintegrator
Copy link
Author

@disintegrator disintegrator changed the title Optional field marker ignored in comprehensions Placeholder expressions and optional markers do not work together Nov 17, 2022
@disintegrator
Copy link
Author

@myitcv myitcv added FeatureRequest New feature or request and removed NeedsInvestigation Triage Requires triage/attention labels Nov 21, 2022
@myitcv myitcv changed the title Placeholder expressions and optional markers do not work together language: support optional markers for dynamic fields Nov 21, 2022
@myitcv
Copy link
Member

myitcv commented Nov 21, 2022

Marking as a feature request, because this is simply not supported yet. Arguably there should be a syntax error in the linked example until it is supported.

@disintegrator
Copy link
Author

disintegrator commented Nov 29, 2022

Marking as a feature request, because this is simply not supported yet. Arguably there should be a syntax error in the linked example until it is supported.

Marking it as a feature request makes sense to but I do think it's a bug to allow an unsupported syntax to pass silently.

@mpvl
Copy link
Member

mpvl commented Feb 2, 2023

Marked this as v0.6. With the eminent changes to optional field representations, this will be easy to make work. So rather than throwing an error, we will make this work.

For now, you can write this as:

[geo]: _value

@disintegrator
Copy link
Author

Thanks @mpvl! I'll keep on eye on it.

@myitcv
Copy link
Member

myitcv commented Apr 6, 2023

@disintegrator - just to flag this got completed in c3138e3. Our bot doesn't do a good job of notifying when things get done!

@disintegrator
Copy link
Author

@myitcv amazing, thank you all!

@jpluscplusm
Copy link
Collaborator

@myitcv thanks to any and all involved in adding this feature :-) May I ask which release you anticipate it'll be available in?

@myitcv
Copy link
Member

myitcv commented Apr 6, 2023

@jpluscplusm it's already present in tip at the commit indicate, which means it's available in the pseudo version v0.6.0-0.dev.0.20230323113716-c3138e362ec8. The next version we will be tagging based on tip is an alpha of v0.6.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants