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

Make Rationals remember where they divided by 0 #5659

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lizmat
Copy link
Contributor

@lizmat lizmat commented Oct 13, 2024

Inspired by #3738

This stores a handled Failure with the location where the Rational was created, and throws that whenever it is being stringified.

my $a = 0;
my $b = 1 / $a;
say "inbetween"
say $b;

results in:

Attempt to divide 1 by zero
  in "foo" at $file line 2

Actually thrown at:
  in "foo" at $file line 4

Passes all tests, but makes handling of Rationals up to 30% slower.

Inspired by #3738

This stores a handled Failure with the location where the Rational
was created, and throws that whenever it is being stringified.

    my $a = 0;
    my $b = 1 / $a;
    say "inbetween"
    say $b;

results in:

    Attempt to divide 1 by zero
      in "foo" at $file line 2

    Actually thrown at:
      in "foo" at $file line 4

Passes all tests, but makes handling of Rationals up to 30% slower.
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

Successfully merging this pull request may close these issues.

1 participant