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

Assigning Failure to typed variable swallows Failure information #4661

Closed
p6rt opened this issue Oct 19, 2015 · 7 comments
Closed

Assigning Failure to typed variable swallows Failure information #4661

p6rt opened this issue Oct 19, 2015 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Oct 19, 2015

Migrated from rt.perl.org#126394 (status was 'resolved')

Searchable as RT126394$

@p6rt
Copy link
Author

p6rt commented Oct 19, 2015

From carsten.hartenfels@googlemail.com

This bug is for Rakudo version 2015.09-419-gfae01fb built on MoarVM
version 2015.09-79-gee9fc2b, according to `perl6 --version`.

The following code, in `t.pl`​:

  sub s { fail 'important failure message' }
  my Int $x = s();
  say $x;

will output​:

  Type check failed in assignment to $x; expected Int but got Failure
  in block <unit> at t.pl​:2

But it omits the important failure message, as well as where it was
actually thrown. Opposed to that, omitting the type​:

  sub s { fail 'important failure message' }
  my $x = s();
  say $x;

will output the much more useful message​:

  important failure message
  in sub s at t.pl​:1
  in block <unit> at t.pl​:2

  Actually thrown at​:
  in block <unit> at t.pl​:3

This seems to make typed variables much less useful, since they
potentially eat failure messages every time you assign to them.

Ideally, the type check message would include the failure information
too, something like​:

  Type check failed in assignment to $x; expected Int but got Failure
  important failure message
  in sub s at t.pl​:1
  in block <unit> at t.pl​:2

@p6rt
Copy link
Author

p6rt commented Oct 19, 2015

From @lizmat

Fixed with a31cc91a0d604a8a74529 . Tests are still needed

On 19 Oct 2015, at 03​:42, Carsten Hartenfels (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Carsten Hartenfels
# Please include the string​: [perl #​126394]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126394 >

This bug is for Rakudo version 2015.09-419-gfae01fb built on MoarVM
version 2015.09-79-gee9fc2b, according to `perl6 --version`.

The following code, in `t.pl`​:

sub s { fail 'important failure message' }
my Int $x = s();
say $x;

will output​:

Type check failed in assignment to $x; expected Int but got Failure
in block <unit> at t.pl​:2

But it omits the important failure message, as well as where it was
actually thrown. Opposed to that, omitting the type​:

sub s { fail 'important failure message' }
my $x = s();
say $x;

will output the much more useful message​:

important failure message
in sub s at t.pl​:1
in block <unit> at t.pl​:2

Actually thrown at​:
in block <unit> at t.pl​:3

This seems to make typed variables much less useful, since they
potentially eat failure messages every time you assign to them.

Ideally, the type check message would include the failure information
too, something like​:

Type check failed in assignment to $x; expected Int but got Failure
important failure message
in sub s at t.pl​:1
in block <unit> at t.pl​:2

@p6rt
Copy link
Author

p6rt commented Oct 19, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 19, 2015

From @TimToady

On Mon Oct 19 07​:02​:44 2015, elizabeth wrote​:

Fixed with a31cc91a0d604a8a74529 . Tests are still needed

On 19 Oct 2015, at 03​:42, Carsten Hartenfels (via RT) <perl6-bugs-
followup@​perl.org> wrote​:

# New Ticket Created by Carsten Hartenfels
# Please include the string​: [perl #​126394]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126394 >

This bug is for Rakudo version 2015.09-419-gfae01fb built on MoarVM
version 2015.09-79-gee9fc2b, according to `perl6 --version`.

The following code, in `t.pl`​:

sub s { fail 'important failure message' }
my Int $x = s();
say $x;

will output​:

Type check failed in assignment to $x; expected Int but got Failure
in block <unit> at t.pl​:2

But it omits the important failure message, as well as where it was
actually thrown. Opposed to that, omitting the type​:

sub s { fail 'important failure message' }
my $x = s();
say $x;

will output the much more useful message​:

important failure message
in sub s at t.pl​:1
in block <unit> at t.pl​:2

Actually thrown at​:
in block <unit> at t.pl​:3

This seems to make typed variables much less useful, since they
potentially eat failure messages every time you assign to them.

Ideally, the type check message would include the failure information
too, something like​:

Type check failed in assignment to $x; expected Int but got Failure
important failure message
in sub s at t.pl​:1
in block <unit> at t.pl​:2

The existing 'method priors' wasn't working correctly due to a precedence error originally made by TimToady-- that ate the priors result as part of the ??!! conditional. Simply adding a "do" fixes that and renders the previous patch unnecessary. Fixed in 48a0888cced2e772d9b347460a69507fc822bd2d (tests still needed).

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 19, 2015

From @TimToady

On Mon Oct 19 07​:02​:44 2015, elizabeth wrote​:

Fixed with a31cc91a0d604a8a74529 . Tests are still needed

On 19 Oct 2015, at 03​:42, Carsten Hartenfels (via RT) <perl6-bugs-
followup@​perl.org> wrote​:

# New Ticket Created by Carsten Hartenfels
# Please include the string​: [perl #​126394]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126394 >

This bug is for Rakudo version 2015.09-419-gfae01fb built on MoarVM
version 2015.09-79-gee9fc2b, according to `perl6 --version`.

The following code, in `t.pl`​:

sub s { fail 'important failure message' }
my Int $x = s();
say $x;

will output​:

Type check failed in assignment to $x; expected Int but got Failure
in block <unit> at t.pl​:2

But it omits the important failure message, as well as where it was
actually thrown. Opposed to that, omitting the type​:

sub s { fail 'important failure message' }
my $x = s();
say $x;

will output the much more useful message​:

important failure message
in sub s at t.pl​:1
in block <unit> at t.pl​:2

Actually thrown at​:
in block <unit> at t.pl​:3

This seems to make typed variables much less useful, since they
potentially eat failure messages every time you assign to them.

Ideally, the type check message would include the failure information
too, something like​:

Type check failed in assignment to $x; expected Int but got Failure
important failure message
in sub s at t.pl​:1
in block <unit> at t.pl​:2

The existing 'method priors' wasn't working correctly due to a precedence error originally made by TimToady-- that ate the priors result as part of the ??!! conditional. Simply adding a "do" fixes that and renders the previous patch unnecessary. Fixed in 48a0888cced2e772d9b347460a69507fc822bd2d (tests still needed).

@p6rt
Copy link
Author

p6rt commented Apr 8, 2018

From @AlexDaniel

jmerelo++, tests added in Raku/roast@ce173d4

Closing

On 2015-10-19 07​:43​:11, larry wrote​:

On Mon Oct 19 07​:02​:44 2015, elizabeth wrote​:

Fixed with a31cc91a0d604a8a74529 . Tests are still needed

On 19 Oct 2015, at 03​:42, Carsten Hartenfels (via RT) <perl6-bugs-
followup@​perl.org> wrote​:

# New Ticket Created by Carsten Hartenfels
# Please include the string​: [perl #​126394]
# in the subject line of all future correspondence about this
issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126394 >

This bug is for Rakudo version 2015.09-419-gfae01fb built on MoarVM
version 2015.09-79-gee9fc2b, according to `perl6 --version`.

The following code, in `t.pl`​:

sub s { fail 'important failure message' }
my Int $x = s();
say $x;

will output​:

Type check failed in assignment to $x; expected Int but got Failure
in block <unit> at t.pl​:2

But it omits the important failure message, as well as where it was
actually thrown. Opposed to that, omitting the type​:

sub s { fail 'important failure message' }
my $x = s();
say $x;

will output the much more useful message​:

important failure message
in sub s at t.pl​:1
in block <unit> at t.pl​:2

Actually thrown at​:
in block <unit> at t.pl​:3

This seems to make typed variables much less useful, since they
potentially eat failure messages every time you assign to them.

Ideally, the type check message would include the failure
information
too, something like​:

Type check failed in assignment to $x; expected Int but got Failure
important failure message
in sub s at t.pl​:1
in block <unit> at t.pl​:2

The existing 'method priors' wasn't working correctly due to a
precedence error originally made by TimToady-- that ate the priors
result as part of the ??!! conditional. Simply adding a "do" fixes
that and renders the previous patch unnecessary. Fixed in
48a0888cced2e772d9b347460a69507fc822bd2d (tests still needed).

@p6rt p6rt closed this as completed Apr 8, 2018
@p6rt
Copy link
Author

p6rt commented Apr 8, 2018

@AlexDaniel - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant