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

Circularity detected when adding a constraint to an &infix:<+> candidate #5162

Open
grondilu opened this issue Jan 20, 2023 · 0 comments
Open

Comments

@grondilu
Copy link
Contributor

grondilu commented Jan 20, 2023

The Problem

I encountered a circularity detection error when adding a multi candidate to &infix:<+>. It was very likely a false positive as this candidate was precisely added to fix a message from the compiler about the lack of a candidate.

Expected Behavior

No circularity detection.

Actual Behavior

Circularity detected.

Steps to Reproduce

Here is my attempt at a minimal code to reproduce the error :

class {
  class Foo { has $.x; }
  multi method new(Real $r) { ::?CLASS }

  multi infix:<+>(::?CLASS $a, ::?CLASS $b) { ::?CLASS }
  multi infix:<+>(Real $r, ::?CLASS $y) { samewith ::?CLASS.new($r), $y }

  # When removing the constraint below, no circularity is detected.
  multi infix:<+>(Real $r, Foo $y where $y.x == 1) { samewith $r, ::?CLASS }

  say 1 + Foo.new;
}

Notice that the issue does not occur if instead of adding candidates to &infix:<+>, I create a brand new sub, say &foo.

Environment

  • Operating system: fedora-37
  • Compiler version: v2022.12-1-gd52342eb0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant