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

spec: comparable explanation is self-contradictory #2026

Open
rogpeppe opened this issue Oct 20, 2022 · 1 comment
Open

spec: comparable explanation is self-contradictory #2026

rogpeppe opened this issue Oct 20, 2022 · 1 comment
Labels
Documentation roadmap/language-changes Specific tag for roadmap issue #339

Comments

@rogpeppe
Copy link
Member

rogpeppe commented Oct 20, 2022

In the spec, the documentation for comparison operators says:

In any comparison, the types of the two operands must unify or one of the operands must be null.

But that's not always the case in practice. For example, the following code is currently valid:

a: 1.0
b: int & 1
c: a == b

But this contradicts the spec, because a does not unify with b and neither operand is null.
For example this code:

a: 1.0
b: int & 1
c: a & b

gives this error:

c: conflicting values 1.0 and int (mismatched types float and int):
    ./x.cue:1:4
    ./x.cue:2:4
    ./x.cue:3:8

The spec should also state explicitly the rules for comparison against _|_, which clearly does not unify against anything except _|_ itself, but in fact appears to be comparable against anything in a similar fashion to null.

@myitcv myitcv added the zGarden label Jun 13, 2023
@mpvl mpvl added the roadmap/language-changes Specific tag for roadmap issue #339 label Jun 14, 2023
@mpvl mpvl added this to the v0.8.0: semantic adjustments milestone Jun 14, 2023
@mpvl
Copy link
Member

mpvl commented Jun 14, 2023

We are considering changing the spec to allow any concrete value to be comparable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation roadmap/language-changes Specific tag for roadmap issue #339
Projects
None yet
Development

No branches or pull requests

3 participants