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

No X::TypeCheck when pushing something with a wrong type to a native typed array #4223

Closed
p6rt opened this issue May 6, 2015 · 6 comments
Closed

Comments

@p6rt
Copy link

p6rt commented May 6, 2015

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

Searchable as RT125123$

@p6rt
Copy link
Author

p6rt commented May 6, 2015

From @usev6

Two tests in S02-types/array-shapes.t fail, because pushing a string to a typed array of type 'int' dies with X​::AdHoc instead of X​::TypeCheck​:

$ perl6-m -e 'my int @​a; push @​a, "s"'
This type cannot unbox to a native integer
  in block <unit> at -e​:1

$ perl6-m -e 'my Int @​a; push @​a, "s"'
Type check failed in .push; expected 'Int' but got 'Str'
  in block <unit> at -e​:1

@p6rt
Copy link
Author

p6rt commented May 6, 2015

From @lizmat

On 06 May 2015, at 22​:15, Christian Bartolomaeus (via RT) <perl6-bugs-followup@​perl.org> wrote​:

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

Two tests in S02-types/array-shapes.t fail, because pushing a string to a typed array of type 'int' dies with X​::AdHoc instead of X​::TypeCheck​:

$ perl6-m -e 'my int @​a; push @​a, "s"'
This type cannot unbox to a native integer
in block <unit> at -e​:1

This is because it physically doesn’t fit.

$ perl6-m -e 'my Int @​a; push @​a, "s"'
Type check failed in .push; expected 'Int' but got 'Str'
in block <unit> at -e​:1

This is because we don’t let it in.

Perhaps the wording of the former can be changed?

Liz

@p6rt
Copy link
Author

p6rt commented May 6, 2015

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

@p6rt
Copy link
Author

p6rt commented Nov 14, 2015

From @moritz

On Wed May 06 13​:56​:21 2015, elizabeth wrote​:

On 06 May 2015, at 22​:15, Christian Bartolomaeus (via RT) <perl6-
bugs-followup@​perl.org> wrote​:

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

Two tests in S02-types/array-shapes.t fail, because pushing a string
to a typed array of type 'int' dies with X​::AdHoc instead of
X​::TypeCheck​:

$ perl6-m -e 'my int @​a; push @​a, "s"'
This type cannot unbox to a native integer
in block <unit> at -e​:1

This is because it physically doesn’t fit.

$ perl6-m -e 'my Int @​a; push @​a, "s"'
Type check failed in .push; expected 'Int' but got 'Str'
in block <unit> at -e​:1

This is because we don’t let it in.

Perhaps the wording of the former can be changed?

It should at least contain the name of the type that can't unbox.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Nov 14, 2015

From @moritz

Hi,

On Wed May 06 13​:15​:51 2015, bartolin@​gmx.de wrote​:

Two tests in S02-types/array-shapes.t fail, because pushing a string
to a typed array of type 'int' dies with X​::AdHoc instead of
X​::TypeCheck​:

$ perl6-m -e 'my int @​a; push @​a, "s"'
This type cannot unbox to a native integer
in block <unit> at -e​:1

$ perl6-m -e 'my Int @​a; push @​a, "s"'
Type check failed in .push; expected 'Int' but got 'Str'
in block <unit> at -e​:1

Fixed with these two commits​:

commit 94ad45b039aa6136ffba3fc791ffc99c9fc2adad
Author​: Moritz Lenz <moritz@​faui2k3.org>
Date​: 2015-11-14 20​:25​:56 +0000

  RT #​125123​: Improve error message when pushing/unshifting to an int-typed array

commit f5fbcde8dfb755c1b6c67b5cfd694d26c5627b16
Author​: Moritz Lenz <moritz@​faui2k3.org>
Date​: 2015-11-14 19​:29​:14 +0000

  RT #​125123​: Improve error message when assigning a Str to a native int array
 
  this works by realizing that the multi-dispatcher unbox for us into the int
  candidate when possible.
 
  The ticket acutally talks about the error message from push, but assignment has the
  same problem.

(not just for .push, but also for .unshift and assignment).

I've adapted the tests in S09-typed-arrays/native-int.t to expect an X​::TypeCheck.

Cheers,
Moritz

@p6rt p6rt closed this as completed Nov 14, 2015
@p6rt
Copy link
Author

p6rt commented Nov 14, 2015

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

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