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

Heterogeneous == #130

Open
divarvel opened this issue Apr 24, 2023 · 1 comment
Open

Heterogeneous == #130

divarvel opened this issue Apr 24, 2023 · 1 comment
Milestone

Comments

@divarvel
Copy link
Collaborator

divarvel commented Apr 24, 2023

Currently, the haskell and rust implementations (amongst others) produce an error on the following expression: 1 == true.

While this makes sense to refuse this expression in a typed language (the equivalent expression would not type check in rust or haskell), this behaviour is a bit more surprising in an untyped langage where such an expression would usually evaluate to false instead of blowing up.

The specification does not explicitly cover this case, and i think it should.

My preference would go to have heterogeneous equality comparisons to not blow up and evaluate to false for two reasons:

  1. out of consistency with untyped languages like JS (or not-very-well typed languages like java);
  2. out of consistency with set inclusion, which is morally equivalent to comparing a value with all values in a set for equality. This operation returns false in the case of heterogeneous values;
  3. because it makes sense in a un(i)typed language: in rust and haskell, all term types are defined in a Term sum type, which defines == by first comparing the constructors, and then values if the constructors are the same (this is why 2. holds).
@Geal
Copy link
Contributor

Geal commented Apr 25, 2023

it also makes sense in the context of unification between facts: if we're matching between facts, and the term we are matching on has different types on both sides, they do not match, but it does not blow up the entire execution

@divarvel divarvel added this to the Datalog update milestone Oct 10, 2023
@divarvel divarvel moved this to Todo in biscuit v5 Oct 10, 2023
@divarvel divarvel moved this from Todo to Design in biscuit v5 Oct 10, 2023
@divarvel divarvel moved this from Design to Implementation in biscuit v5 Oct 10, 2023
divarvel added a commit to biscuit-auth/biscuit-rust that referenced this issue Dec 28, 2023
@divarvel divarvel moved this from Implementation to Done in biscuit v5 Dec 29, 2023
This was referenced May 22, 2024
@divarvel divarvel moved this from Done to Implementation in biscuit v5 May 22, 2024
Geal added a commit to biscuit-auth/biscuit-rust that referenced this issue May 26, 2024
…220)

Context: biscuit-auth/biscuit#130

This introduces the `HeterogeneousEqual` and `HeterogeneousNotEqual` operations, which will not return an error when their operands have different types, contrary to the existing `Equal` and `NotEqual` operations.

**breaking change**: this does not change the execution of existing tokens, but changes the text representation of the language. `Equal` was `==` and is now `===`, `NotEqual` was `!=` and is now `!==`, `HeterogeneousEqual` is `==` and `HeterogeneousNotEqual` is `!=`

---------

Co-authored-by: Geoffroy Couprie <[email protected]>
Co-authored-by: Clément Delafargue <[email protected]>
@divarvel divarvel moved this from Implementation to Done in biscuit v5 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
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants