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

internal/core/adt: add isconcrete builtin func #2605

Closed
wants to merge 1 commit into from
Closed

internal/core/adt: add isconcrete builtin func #2605

wants to merge 1 commit into from

Conversation

bozaro
Copy link
Contributor

@bozaro bozaro commented Sep 20, 2023

This PR implements isconcrete buildin func from #943 proposal.

isconcrete(expr) :: bool

isconcrete reports whether expr resolves to a concrete value, returning true if it does and false otherwise. It is a fatal error if an expression can never evaluate to true.

Motivation: replaces if a.foo != _|_ { field value check without hiding the underlying error.

isconcrete(expr) :: bool

`isconcrete` reports whether expr resolves to a concrete value,
returning true if it does and false otherwise. It is a fatal
error if an expression can never evaluate to true.

Signed-off-by: Artem V. Navrotskiy <[email protected]>
@mvdan mvdan self-assigned this Oct 25, 2023
@fab29p
Copy link

fab29p commented Dec 7, 2023

With the following file, there is a difference in the behavior of isconcrete and the behavior of != _|_ when doing a cue export. Try by commenting the line with a_1 then the line with a_2. The test on a_1 raises an error.

a: "z"
x: {
    y: 1
    
}

let u = {
    for k, v in x {
        (k): v
    }
}

a_1: isconcrete(u[a])
a_2: u[a] != _|_

@fab29p
Copy link

fab29p commented Dec 7, 2023

Notice that

  • the proposal for exists exhibit the same behavior
  • if let u= is replaced by u: then the problem disappear

@joomcode joomcode closed this by deleting the head repository May 29, 2024
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 this pull request may close these issues.

4 participants