-
Notifications
You must be signed in to change notification settings - Fork 287
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
pkg/math: MultipleOf can't be used as a validator #2927
Labels
Comments
In addition, the following relatively natural construct:
fails with:
I guess it's the same error, but might be worth to include in a test case. |
cueckoo
pushed a commit
that referenced
this issue
Apr 19, 2024
The hiddenValue.Decimal() method currently makes the assumption that its function argument is an *adt.Num. This means that the "Validator" form of the builtin math.MultipleOf(n) will not work, because in that case the first argument will be an *adt.Vertex. This changes the explicit interface convertion to instead use the value.Decimal() method, which will work in all cases. Fixes #2927 Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com> Change-Id: I35f780efde92a6523548ed04e1e7a6a960b191ce
cueckoo
pushed a commit
that referenced
this issue
Apr 19, 2024
The hiddenValue.Decimal() method currently makes the assumption that its function argument is an *adt.Num. This means that the "Validator" form of the builtin math.MultipleOf(n) will not work, because in that case the first argument will be an *adt.Vertex. This changes the explicit interface convertion to instead use the value.Decimal() method, which will work in all cases. Fixes #2927 Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com> Change-Id: I35f780efde92a6523548ed04e1e7a6a960b191ce
cueckoo
pushed a commit
that referenced
this issue
Apr 19, 2024
The cue.Value.Decimal method currently makes the assumption that its function argument is an *adt.Num. This means that the "Validator" form of the builtin math.MultipleOf(n) will not work, because in that case the first argument will be an *adt.Vertex. This changes the explicit interface convertion to instead use the cue.value.Decimal method, which will work in all cases. Fixes #2927 Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com> Change-Id: I35f780efde92a6523548ed04e1e7a6a960b191ce
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest stable release?
Yes, 0.7.0
What did you do?
I tried to use
math.MultipleOf
as a validator, which I believe should work given(bool, error)
return typeWhat did you expect to see?
A passing test. Note that the values chosen, 10 and 2, are not affected by #2926.
What did you see instead?
The text was updated successfully, but these errors were encountered: