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

List declarations of lexicals with native types blows up #2540

Closed
p6rt opened this issue Oct 28, 2011 · 7 comments
Closed

List declarations of lexicals with native types blows up #2540

p6rt opened this issue Oct 28, 2011 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Oct 28, 2011

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

Searchable as RT102414$

@p6rt
Copy link
Author

p6rt commented Oct 28, 2011

From @moritz

12​:07 < moritz> nom​: my int ($x, $y);
12​:07 <+p6eval> nom 642e78​: OUTPUT«Lexical '$x' is of wrong register
type in lexical lookup␤ in block <anon> at /tmp/FX3ocH8HsO​:1␤ in
  <anon> at /tmp/FX3ocH8HsO​:1␤»

@p6rt
Copy link
Author

p6rt commented Feb 16, 2012

From @masak

<masak> std​: my int ($a, $b)
<p6eval> std 52f3895​: OUTPUT«ok 00​:01 110m␤»
<masak> nom​: my int ($a, $b); say 'alive'
<p6eval> nom f9fcb2​: OUTPUT«Lexical '$a' is of wrong register type in
lexical lookup [...]
* masak submits rakudobug
<masak> nom​: my (int $a, int $b); say 'alive'
<p6eval> nom f9fcb2​: OUTPUT«Lexical '$a' is of wrong register type in
lexical lookup [...]
<masak> huh!
<masak> nom​: my (int $a); say 'alive'
<p6eval> nom f9fcb2​: OUTPUT«Lexical '$a' is of wrong register type in
lexical lookup [...]
<masak> nom​: my int $a; say 'alive'
<p6eval> nom f9fcb2​: OUTPUT«alive␤»
<masak> still a bug, but not what I thought it was :)

All the declarations above should either Just Work, or throw a better
error message. I have no idea whether the 'my int ($a, $b)' form is
meant to work, but STD.pm6 seems to accept it.

The strange error messages above seem specific to native types, but
other types are problematic too, in that they are not checked if
declared inside the signature​:

<masak> nom​: my (Int $a); $a = "OH HAI"; say 'alive'
<p6eval> nom f9fcb2​: OUTPUT«alive␤»
<masak> nom​: my (Int $a, Int $b); $b = "OH HAI"; say 'alive'
<p6eval> nom f9fcb2​: OUTPUT«alive␤»

Declaring a type the normal way works, of course.

<masak> nom​: my Int $a; $a = "OH HAI"; say 'alive'
<p6eval> nom f9fcb2​: OUTPUT«Type check failed in assignment to '$a';
expected 'Int' but got 'Str' [...]

Having the type declarations within parentheses mean nothing violates
Least Surprise.

@p6rt
Copy link
Author

p6rt commented Mar 1, 2015

From @usev6

skids++ added some tests for this ticket to roast​: Raku/roast@b354a9304f

The declarations with native types don't blow up any longer -- e.g.

$ perl6-j -e 'my (int $a); say "alive"'
alive

The type constraints within the signatures don't work, though​:

$ perl6-m -e 'my (Int $a); $a = "foo"; say "alive"'
alive

$ perl6-m -e 'my (int $a); $a = "foo"; say "alive"'
alive

1 similar comment
@p6rt
Copy link
Author

p6rt commented Mar 1, 2015

From @usev6

skids++ added some tests for this ticket to roast​: Raku/roast@b354a9304f

The declarations with native types don't blow up any longer -- e.g.

$ perl6-j -e 'my (int $a); say "alive"'
alive

The type constraints within the signatures don't work, though​:

$ perl6-m -e 'my (Int $a); $a = "foo"; say "alive"'
alive

$ perl6-m -e 'my (int $a); $a = "foo"; say "alive"'
alive

@p6rt
Copy link
Author

p6rt commented Mar 1, 2015

@usev6 - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Apr 12, 2015

From @jnthn

On Sun Mar 01 12​:22​:34 2015, bartolin@​gmx.de wrote​:

skids++ added some tests for this ticket to roast​:
Raku/roast@b354a9304f

The declarations with native types don't blow up any longer -- e.g.

$ perl6-j -e 'my (int $a); say "alive"'
alive

The type constraints within the signatures don't work, though​:

$ perl6-m -e 'my (Int $a); $a = "foo"; say "alive"'
alive

$ perl6-m -e 'my (int $a); $a = "foo"; say "alive"'
alive

Fixed these now, unfudged the tests in S04-declarations/my.t, and written some extra tests to give better coverage.

@p6rt p6rt closed this as completed Apr 12, 2015
@p6rt
Copy link
Author

p6rt commented Apr 12, 2015

@jnthn - 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