-
Notifications
You must be signed in to change notification settings - Fork 301
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
v0.3.x Fill casts whole-number float to int instead of float #896
Comments
Original reply by @brandoshmando in cuelang/cue#896 (comment) One other note: changing the |
Original reply by @mpvl in cuelang/cue#896 (comment) Analysis: Fill seems to cat the float to float fine. It is actually the conversion to Syntax and back that causes the problem. Ironically enough -- and this explains the difference between v0.2 and v0.3 -- this is a result of a change that makes floats and ints more interchangeable. Basically, syntactically, if a float constant is a whole number, it is allowed to be an integer or a float. This increases interoperability with JSON, where 1.0 is often meant to be interpretable as an integer. See also #253. But something is going wrong in this interpretation, interpreting it too strict as an integer. |
Original reply by @mpvl in cuelang/cue#896 (comment) BTW, this code snippet also seems to indicate it would be useful to people to allow something like |
Original reply by @mpvl in cuelang/cue#896 (comment) Minimal reproducer:
|
Original reply by @brandoshmando in cuelang/cue#896 (comment) @mpvl Thanks for the quick fix! Much appreciated. I kind of figured that it had something to do with the fact that whole number float could be interpreted as int. As for your comment re: Thanks again! |
Originally opened by @brandoshmando in cuelang/cue#896
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
I ran into some interesting behavior changes with the
Fill
function between v0.2.2 and v0.3.x. With v0.3.x, when filling anumber
value with a non-concrete value (i.e. default, gt, lt etc.) that contains a "whole number" float (i.e. 3.0), it seems to cast that value to an int instead of a float. Subsequently, when attempting to fill with a concrete, non-whole number float (i.e. 3.5), an error indicating conflicting values occurs. When testing this same scenario with v0.2.2, the value is filled with the proper float value and no error occurs. In addition to observing this with both v0.3.x versions, I also tested with FillPath in both and observed the same error.I've included a simplified example:
EDIT: better example
Edit
Admittedly, I'm noticing this can be resolved by ensuring that the concrete value is filled after the constraint,
but it'd be nice if we didn't need to worry about order. Also v.2.2.0 does handle this properly.
What did you expect to see?
I expected to fill a concrete value of type float and a non-concrete value operating on the same type, regardless of order, without encountering a conflict.
(the above recipe with v0.2.2 outputs the following)
What did you see instead?
The following error:
The text was updated successfully, but these errors were encountered: