Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Question about Value.IsConcrete()? #883

Closed
verdverm opened this issue Apr 6, 2021 · 2 comments
Closed

Question about Value.IsConcrete()? #883

verdverm opened this issue Apr 6, 2021 · 2 comments

Comments

@verdverm
Copy link
Contributor

verdverm commented Apr 6, 2021

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

0.3.0

What did you do?

Called cue.Value.IsConcrete() via the Go API and got unexpected results. If this does indeed seem like a bug, then I can create a reproducer.

In the example below, calling IsConcrete() for ex.bar. reports true, is this expected?

#A: {
  a1: string
  a2: string | *""
}

#B: {
  foo: string
  bar: #A
}

ex: #B & {
  foo: "foo"
}

What did you expect to see?

ex.bar.IsConcrete() returning false

What did you see instead?

ex.bar.IsConcrete() returning true

@myitcv
Copy link
Contributor

myitcv commented Apr 7, 2021

AFAIU, this is working "as expected" but is effectively the same problem of a list type defaulting to [], picked up in the required fields proposal. i.e. the default value of #A here is {}. What I think you are looking to distinguish is whether ex.bar is specified or not, and that is where the ! proposal comes in.

@mpvl
Copy link
Contributor

mpvl commented Apr 7, 2021

It is working as expected because, as documented, a struct is always considered concrete.

As per the doc:

It does not verify that values of lists or structs are concrete themselves.

@mpvl mpvl closed this as completed Apr 7, 2021
@cuelang cuelang locked and limited conversation to collaborators Apr 7, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

3 participants