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

Strange error when doing '.= new' on an attribute in Rakudo #1741

Closed
p6rt opened this issue May 2, 2010 · 13 comments
Closed

Strange error when doing '.= new' on an attribute in Rakudo #1741

p6rt opened this issue May 2, 2010 · 13 comments
Labels

Comments

@p6rt
Copy link

p6rt commented May 2, 2010

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

Searchable as RT74850$

@p6rt
Copy link
Author

p6rt commented May 2, 2010

From @masak

<masak> rakudo​: class A {}; class B { has A $.foo .= new }
<p6eval> rakudo c4857a​: OUTPUT«too few positional arguments​: 1 passed,
2 (or more) expected [...]
<slavik> s1n​: it will take 1 month to do that ...
* masak submits rakudobug
<masak> alpha​: class A {}; class B { has A $.foo .= new }
<p6eval> alpha 30e0ed​: OUTPUT«error​:imcc​:syntax error, unexpected
'\n'␤ in file 'EVAL_25' line 186␤Null PMC access in
find_method('new') [...]

@p6rt
Copy link
Author

p6rt commented Aug 18, 2010

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

@p6rt
Copy link
Author

p6rt commented Aug 18, 2010

From sohtil@gmail.com

See also #​77200 for a similar[1] error caused by using .= new with a
lexically declared class.

[1]...regarding the message. Don't know about the internals.

@p6rt
Copy link
Author

p6rt commented Oct 21, 2011

From @coke

On Sun May 02 08​:33​:11 2010, masak wrote​:

<masak> rakudo​: class A {}; class B { has A $.foo .= new }
<p6eval> rakudo c4857a​: OUTPUT«too few positional arguments​: 1 passed,
2 (or more) expected [...]
<slavik> s1n​: it will take 1 month to do that ...
* masak submits rakudobug
<masak> alpha​: class A {}; class B { has A $.foo .= new }
<p6eval> alpha 30e0ed​: OUTPUT«error​:imcc​:syntax error, unexpected
'\n'␤ in file 'EVAL_25' line 186␤Null PMC access in
find_method('new') [...]

This now complains about trying to append to an unitialized string,
which seems reasonable​:

15​:51 < [Coke]> rakudo​: class A {}; class B { has A $.foo .= new }
15​:51 <+p6eval> rakudo 142c41​: OUTPUT«Use of uninitialized value in
string
  context␤Use of uninitialized value in string
  context␤===SORRY!===␤error​:imcc​:syntax error,
unexpected DOT
  ('.')␤ in file '(file unknown)' line 371␤␤»

Closable with tests.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Oct 21, 2011

From @coke

On Fri, Oct 21, 2011 at 3​:52 PM, Will Coleda via RT
<perl6-bugs-followup@​perl.org> wrote​:

On Sun May 02 08​:33​:11 2010, masak wrote​:

<masak> rakudo​: class A {}; class B { has A $.foo .= new }
<p6eval> rakudo c4857a​: OUTPUT«too few positional arguments​: 1 passed,
2 (or more) expected [...]
<slavik> s1n​: it will take 1 month to do that ...
* masak submits rakudobug
<masak> alpha​: class A {}; class B { has A $.foo .= new }
<p6eval> alpha 30e0ed​: OUTPUT«error​:imcc​:syntax error, unexpected
'\n'␤   in file 'EVAL_25' line 186␤Null PMC access in
find_method('new') [...]

This now complains about trying to append to an unitialized string,
which seems reasonable​:

15​:51 < [Coke]> rakudo​: class A {}; class B { has A $.foo .= new }
15​:51 <+p6eval> rakudo 142c41​: OUTPUT«Use of uninitialized value in
string
               context␤Use of uninitialized value in string
               context␤===SORRY!===␤error​:imcc​:syntax error,
unexpected DOT
               ('.')␤     in file '(file unknown)' line 371␤␤»

Closable with tests.

--
Will "Coke" Coleda

Whoa. much less reasonable is that IMCC error hidden in the output
there. I take back the closable bit.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @diakopter

On Fri Oct 21 12​:55​:20 2011, coke wrote​:

On Fri, Oct 21, 2011 at 3​:52 PM, Will Coleda via RT
<perl6-bugs-followup@​perl.org> wrote​:

On Sun May 02 08​:33​:11 2010, masak wrote​:

<masak> rakudo​: class A {}; class B { has A $.foo .= new }
<p6eval> rakudo c4857a​: OUTPUT«too few positional arguments​: 1
passed,
2 (or more) expected [...]
<slavik> s1n​: it will take 1 month to do that ...
* masak submits rakudobug
<masak> alpha​: class A {}; class B { has A $.foo .= new }
<p6eval> alpha 30e0ed​: OUTPUT«error​:imcc​:syntax error, unexpected
'\n'␤   in file 'EVAL_25' line 186␤Null PMC access in
find_method('new') [...]

This now complains about trying to append to an unitialized string,
which seems reasonable​:

15​:51 < [Coke]> rakudo​: class A {}; class B { has A $.foo .= new }
15​:51 <+p6eval> rakudo 142c41​: OUTPUT«Use of uninitialized value in
string
               context␤Use of uninitialized value in string
               context␤===SORRY!===␤error​:imcc​:syntax error,
unexpected DOT
               ('.')␤     in file '(file unknown)' line 371␤␤»

Closable with tests.

--
Will "Coke" Coleda

Whoa. much less reasonable is that IMCC error hidden in the output
there. I take back the closable bit.

it is now much more reasonable. marking testneeded.

13​:53 <diakopter> rakudo​: class A {}; class B { has A $.foo .= new }
13​:53 <p6eval> rakudo e2d876​: OUTPUT«===SORRY!===␤Cannot use .= to
initialize an attribute
  at line 2, near " }"␤»

@p6rt
Copy link
Author

p6rt commented Jul 15, 2012

From @bbkr

Test in

Raku/roast@84fa0c2df0

@p6rt
Copy link
Author

p6rt commented Jul 15, 2012

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

@p6rt
Copy link
Author

p6rt commented Jul 16, 2012

From @bbkr

Reopening because this is limitation of Rakudo, not Spec​:

moritz bbkr​: is that behavior specced? 22​:19
moritz or is that a limitation in rakudo? 22​:19
moritz nr​: class A { has Array $x .= new }; A.new 22​:20
p6eval niecza v19-13-g442e075​: OUTPUT«Unhandled exception​: Unable to resolve
method ctxzyg in type Method␤ at /home/p6eval/niecza/src/NieczaPassSimplifier.pm6 line
162 (run_optree @​ 8) ␤ at /home/p6eval/niecza/src/NieczaPassSimplifier.pm6 line 19
(NieczaPassSimplifier.invoke_incr @​ 5) ␤ at … 22​:20
p6eval ..rakudo 1fe39c​: OUTPUT«===SORRY!===␤Cannot use .= to initialize an
attribute at line 2, near " }; A.new"␤» 22​:20
sorear bbkr​: proper form these days is to smartmatch on types like X​::Foo
22​:20
sorear bbkr​: this doesn't work on niecza, I know :| but it's clearly the right way going
forward 22​:20
moritz sorear​: do you think the example above (has Type $.x .= new) should work?
22​:21
sorear moritz​: Yes 22​:21
moritz then the proper thing is to test that it works 22​:21
moritz and then both rakudo and niecza fail the test 22​:21
moritz except that rakudo has the nicer error message 22​:22
bbkr I'll reverse test logic and fudge it for Rakudo and Niecza 22​:22
sorear good point, I wasn't even looking at the test itself :D 22​:22
sorear moritz​: saying that Rakudo has the nicer error message implies that Niecza
has an error message at all, which I would dispute :D 22​:22
moritz sorear​: it prints something in the case of an error, so I'd call it an "error
message" :-) 22​:23
bbkr also RT should be reopened here, am I right? 22​:23
moritz yes

@p6rt
Copy link
Author

p6rt commented Jul 16, 2012

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

@p6rt
Copy link
Author

p6rt commented Jul 16, 2012

From @bbkr

fudged test in

Raku/roast@506d0a59c5

@p6rt
Copy link
Author

p6rt commented Feb 15, 2015

From @Mouq

Fixed in Rakudo commit​:

commit df5b31eae0cdecd36d7aa92ea07fdec4843de051
Author​: Mouq <alexmoquin@​gmail.com>
Date​: Sat Feb 14 20​:57​:56 2015 -0500

  Implement #​74850 "has Array $.x .= new(1, 2, 3);"

And the test bbkr++ mentioned was unfudged.

Closing as resolved :)

On Mon Jul 16 13​:33​:54 2012, bbkr wrote​:

fudged test in

Raku/roast@506d0a59c5

@p6rt
Copy link
Author

p6rt commented Feb 15, 2015

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

@p6rt p6rt closed this as completed Feb 15, 2015
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant