Skip to content

evalv3 regression where a pattern constraint definition allows non-matching field #3670

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

Closed
dsbenghe opened this issue Jan 10, 2025 · 1 comment
Labels
closedness evaluator evalv3 issues affecting only the evaluator version 3

Comments

@dsbenghe
Copy link

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

cue version v0.11.1

go version go1.23.4
-buildmode exe
-compiler gc
-trimpath true
CGO_ENABLED 0
GOARCH amd64
GOOS windows
GOAMD64 v1
cue.lang.version v0.11.1

Does this issue reproduce with the latest stable release?

yes

What did you do?

#ContainerVersion: [int]: string

containersMap: #ContainerVersion
containersMap: "someid": "sometag"

What did you expect to see?

An error to happen as string doesn't match the int

What did you see instead?

CUE_EXPERIMENT="evalv3,toposort,embed"

cue export -e containersMap

{
"someid": "sometag"
}

It errors out fine if evalv3 experiment is not enabled.

@dsbenghe dsbenghe added NeedsInvestigation Triage Requires triage/attention labels Jan 10, 2025
@dsbenghe dsbenghe changed the title evalv3 regression: Pattern constraint evalv3 regression: Not matching pattern constraint does not fail Jan 10, 2025
@dsbenghe dsbenghe changed the title evalv3 regression: Not matching pattern constraint does not fail evalv3: Not matching pattern constraint does not fail Jan 10, 2025
@mvdan
Copy link
Member

mvdan commented Jan 12, 2025

Thank you for reporting; this does indeed look like a regression. Here is a simpler reproducer in testscript form:

# With the old evaluator.
env CUE_EXPERIMENT=evalv3=0
exec cue vet -c

# With the new evaluator.
env CUE_EXPERIMENT=evalv3=1
exec cue vet -c

-- input.cue --
package p

#Schema: [int]: string

data: #Schema
data: "foo": "bar"

As of 15f243b, I see:

# With the old evaluator. (0.010s)
> env CUE_EXPERIMENT=evalv3=0
> exec cue vet -c
[stderr]
data.foo: field not allowed:
    ./input.cue:3:10
    ./input.cue:5:7
    ./input.cue:6:7
[exit status 1]
FAIL: repro-evalv3.txtar:3: unexpected command failure
# With the new evaluator. (0.028s)
> env CUE_EXPERIMENT=evalv3=1
> exec cue vet -c

The old evaluator correctly fails, but the new evaluator succeeds unexpectedly.

@mvdan mvdan added closedness evaluator evalv3 issues affecting only the evaluator version 3 and removed NeedsInvestigation Triage Requires triage/attention labels Jan 12, 2025
@mvdan mvdan changed the title evalv3: Not matching pattern constraint does not fail evalv3 regression where a pattern matching definition allows non-matching field Jan 12, 2025
@mvdan mvdan changed the title evalv3 regression where a pattern matching definition allows non-matching field evalv3 regression where a pattern constraint definition allows non-matching field Jan 12, 2025
cueckoo pushed a commit that referenced this issue Jan 15, 2025
Issue #3670

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: Ifd2fd8ee07192a47719372d218fdb0e2b30cf1bc
Reviewed-on: https://gerrithub.io/c/cue-lang/cue/+/1207257
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closedness evaluator evalv3 issues affecting only the evaluator version 3
Projects
None yet
Development

No branches or pull requests

2 participants