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

"Calling x will never work with the declared signature" error when EVAL is done in a BEGIN block #2779

Open
gfldex opened this issue Mar 21, 2019 · 26 comments

Comments

@gfldex
Copy link
Contributor

gfldex commented Mar 21, 2019

use WWW;
my @stations;
@stations = | jpost "https://www.perl6.org", :limit(42);

OUTPUT:

Type check failed in binding to parameter '$s'; expected Str but got Int (42)
  in sub jpost at /home/bisect/.perl6/sources/674E3526955FCB738B7B736D9DBBD3BD5B162E5C (WWW) line 9
  in block <unit> at wrong-line-or-identifier.p6 line 3

There parameter $s is nowhere to be found. That includes the routines called in WWW.
This used to work just fine. The last good commit is da2b758 2019.03.1 built on MoarVM version 2019.03. Interestingly this bug apeard before the last good commit a few times too.

@gfldex
Copy link
Contributor Author

gfldex commented Mar 21, 2019

bisect log:

running 1 787d5bf This is Rakudo version 2019.03.1-102-g787d5bf6e built on MoarVM version 2019.03-44-g079d67002 FAIL
running 2 c566430 This is Rakudo version 2019.03.1-101-gc5664301b built on MoarVM version 2019.03-44-g079d67002 FAIL
running 3 6365798 This is Rakudo version 2019.03.1-100-g63657986f built on MoarVM version 2019.03-44-g079d67002 FAIL
running 4 1f066d9 This is Rakudo version 2019.03.1-99-g1f066d96a built on MoarVM version 2019.03-44-g079d67002 FAIL
running 5 a6a6070 This is Rakudo version 2019.03.1-98-ga6a607054 built on MoarVM version 2019.03-44-g079d67002 FAIL
running 6 9399ea1 This is Rakudo version 2019.03.1-97-g9399ea119 built on MoarVM version 2019.03-44-g079d67002 FAIL
running 7 0e07079 This is Rakudo version 2019.03.1-96-g0e07079ba built on MoarVM version 2019.03-44-g079d67002 FAIL
running 8 4189e20 This is Rakudo version 2019.03.1-95-g4189e20c4 built on MoarVM version 2019.03-44-g079d67002 FAIL
running 9 68c2c9f This is Rakudo version 2019.03.1-94-g68c2c9fea built on MoarVM version 2019.03-44-g079d67002 FAIL
running 10 f9aebab This is Rakudo version 2019.03.1-93-gf9aebab53 built on MoarVM version 2019.03-44-g079d67002 FAIL
running 11 e20dcc4 This is Rakudo version 2019.03.1-92-ge20dcc4e9 built on MoarVM version 2019.03-44-g079d67002 FAIL
skipping 12 7a3f468
skipping 13 1d53897
skipping 14 1add622
skipping 15 efb35b0
skipping 16 4a7c487
skipping 17 090f1c9
skipping 18 a542ec9
skipping 19 9e63da4
skipping 20 ffaf3fc
skipping 21 1853eb9
skipping 22 637ba57
skipping 23 27adb55
skipping 24 52b80c4
running 25 0cc563c This is Rakudo version 2019.03.1-54-g0cc563c87 built on MoarVM version 2019.03-35-gd15906711 FAIL
skipping 26 472c8c9
skipping 27 4ec400b
skipping 28 e00c9ea
skipping 29 e0f84e0
skipping 30 f0915e9
skipping 31 ab96f1a
skipping 32 2c9c823
skipping 33 4b461bf
skipping 34 98a0df6
skipping 35 f20a2b6
skipping 36 aed2923
skipping 37 2633aad
skipping 38 d76fe0a
skipping 39 9196db5
skipping 40 f76db01
skipping 41 8055fc1
skipping 42 5366c4f
skipping 43 7ab1981
running 44 ed9b963 This is MoarVM version 2019.03-35-gd15906711 built with JIT support FAIL
running 45 a11e9ab This is Rakudo version 2019.03.1-58-ga11e9ab50 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 46 171bb6e This is Rakudo version 2019.03.1-57-g171bb6eb5 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 47 efa9f54 This is Rakudo version 2019.03.1-56-gefa9f54ee built on MoarVM version 2019.03-35-gd15906711 FAIL
skipping 48 e27c1ec
skipping 49 b989882
running 50 67594c0 This is Rakudo version 2019.03.1-53-g67594c0b3 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 51 8018503 This is Rakudo version 2019.03.1-52-g801850319 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 52 6599998 This is Rakudo version 2019.03.1-51-g6599998c2 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 53 ed074cd This is Rakudo version 2019.03.1-50-ged074cd17 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 54 45eb1c5 This is Rakudo version 2019.03.1-49-g45eb1c5f3 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 55 4825f31 This is Rakudo version 2019.03.1-48-g4825f31e2 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 56 76b6416 This is Rakudo version 2019.03.1-47-g76b6416d0 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 57 6d8077c This is Rakudo version 2019.03.1-46-g6d8077cec built on MoarVM version 2019.03-35-gd15906711 FAIL
running 58 23d215d This is Rakudo version 2019.03.1-45-g23d215dc4 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 59 cc261f6 This is Rakudo version 2019.03-49-gcc261f62d built on MoarVM version 2019.03-35-gd15906711 FAIL
running 60 da2b758 This is Rakudo version 2019.03.1 built on MoarVM version 2019.03 OK
running 61 cb29b8d This is Rakudo version 2019.03-5-gcb29b8d16 built on MoarVM version 2019.03 OK
running 62 678e007 This is Rakudo version 2019.03-4-g678e00711 built on MoarVM version 2019.03 OK
running 63 936eaf6 This is Rakudo version 2019.03-3-g936eaf626 built on MoarVM version 2019.03 OK
running 64 2f9d69c This is Rakudo version 2019.03-2-g2f9d69c23 built on MoarVM version 2019.03 OK
running 65 190a714 This is Rakudo version 2019.03-1-g190a7148f built on MoarVM version 2019.03 OK
running 66 ffe8409 This is Rakudo version 2019.03-43-gffe840999 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 67 ec40933 This is Rakudo version 2019.03-42-gec40933d3 built on MoarVM version 2019.03-35-gd15906711 FAIL
running 68 fc4aca0 This is Rakudo version 2019.03-41-gfc4aca08f built on MoarVM version 2019.03-35-gd15906711 FAIL
running 69 4ffb408 This is Rakudo version 2019.03-40-g4ffb4082b built on MoarVM version 2019.03-31-g6c7810ce7 FAIL
running 70 23fca8f This is Rakudo version 2019.03-39-g23fca8f6f built on MoarVM version 2019.03-31-g6c7810ce7 OK
running 71 29878d8 This is Rakudo version 2019.03-38-g29878d823 built on MoarVM version 2019.03-31-g6c7810ce7 OK
running 72 c21054d This is Rakudo version 2019.03-37-gc21054de6 built on MoarVM version 2019.03-31-g6c7810ce7 OK
running 73 7bd3b3a This is Rakudo version 2019.03-36-g7bd3b3a0a built on MoarVM version 2019.03-31-g6c7810ce7 OK

@AlexDaniel AlexDaniel added the BLOCKER Preventing the next release of rakudo, or just needing attention before the release label Mar 25, 2019
@lizmat lizmat changed the title regession in WWW Regression in WWW Mar 25, 2019
@lizmat
Copy link
Contributor

lizmat commented Mar 25, 2019

I've golfed this to:

$ perl6 --ll-exception -e 'use WWW; dd jpost "https://www.perl6.org"'
Failure.new(exception => X::AdHoc.new(payload => "at 1: expected a json object, but got < (context: \"<!DOCTYP\")"), backtrace => Backtrace.new)

which is quite a different error? This is on:
This is Rakudo version 2019.03.1-114-g888cf8c built on MoarVM version 2019.03-44-g079d670

AlexDaniel added a commit to Raku/Blin that referenced this issue Mar 25, 2019
So that users can bisect arbitrary code. The code can depend on
modules, in which case these have to be listed on the command line
(e.g. for a script depending on WWW you should list WWW module,
dependencies will be detected automatically).

Using this ticket as an example: rakudo/rakudo#2779

Create file foo.p6 with this content:

    use WWW;
    my @StationS;
    @StationS = | jpost "https://www.perl6.org", :limit(42);

Then run Blin:

    ./bin/blin.p6 --old=2018.12 --new=HEAD --custom-script=foo.p6 WWW

Then check out the output folder to see the results.

Resolves #11.
@AlexDaniel
Copy link
Contributor

Looking at the blog post, I realized that there's a problem with tooling. So now it's possible to use Blin with custom scripts! @gfldex++

@gfldex
Copy link
Contributor Author

gfldex commented Mar 26, 2019

@lizmat: You golfed the bug away. What you got is expected, because jpost is calling from-json.

@lizmat
Copy link
Contributor

lizmat commented Mar 26, 2019 via email

@gfldex
Copy link
Contributor Author

gfldex commented Mar 27, 2019

tracked on travis via https://travis-ci.org/gfldex/perl6-hard-tests

@AlexDaniel
Copy link
Contributor

@gfldex not sure what your plan for perl6-hard-tests repo is, it looks promising. However, if you add the same test to WWW itself, we would notice this issue before the release (if the problem appears again). Looking at https://github.com/perl6/ecosystem-unbitrot, there's no ticket for WWW, meaning that the tests were green before the release. And Blin bisected the issue to 4ffb408 (similarly to your results)… However, the current status of WWW module is AlwaysFail meaning that the issue is also present on older releases… It's contradicting, I'm really confused by this.

@gfldex
Copy link
Contributor Author

gfldex commented Mar 28, 2019

That repo is running on a travis cron job once a week. If by chance a future Rakudo commit fixes this bug as well, I will get an e-mail. That may allow to narrow it down. I would come up with a better idea if I had one.

@JJ
Copy link
Collaborator

JJ commented Apr 29, 2019

Just run travis again over a PR I did some time ago, with the test results being a bit more informative: https://travis-ci.org/perl6-community-modules/perl6-WWW/builds/491289924?utm_source=github_status&utm_medium=notification
Will probably have to work it over, but I wouldn't set this as a blocker, it's code that hasn't been touched in a year and it's probably drifted away from spec.
And the $s it refers to is here:

    #      got: $(Failure.new(exception => X::TypeCheck::Binding::Parameter.new(parameter => Str $s, constraint => Bool::False, symbol => "\$s", operation => Any, got => 72, expected => Str), backtrace => Backtrace.new), Failure.new(exception => X::TypeCheck::Binding::Parameter.new(parameter => Str $s, constraint => Bool::False, symbol => "\$s", operation => Any, got => 72, expected => Str), backtrace => Backtrace.new))

@JJ
Copy link
Collaborator

JJ commented Apr 29, 2019

OTOH, and just as a reminder, LWP::Simple works correctly (AFAIK)

@JJ
Copy link
Collaborator

JJ commented Apr 29, 2019

I have merged my pull request and tested it locally, and there does not seem to be a problem. I'm going to run more tests to see if I find out what.

@JJ
Copy link
Collaborator

JJ commented Apr 29, 2019

The error is here:
https://github.com/sergot/http-useragent/blob/master/lib/HTTP/Request.pm6#L170

72 goes all the way through as an Int, but that function requires a String. I'm not sure how to mitigate that, of where the error is along the line. I'll try to see if I can fix it there in origin and submit a PR.

@JJ
Copy link
Collaborator

JJ commented Apr 29, 2019

That was introduced in Feb 28th here:
sergot/http-useragent@26e0d5c
So timeline makes sense.

@JJ
Copy link
Collaborator

JJ commented Apr 29, 2019

Posted a patch: /sergot/http-useragent#223
At any rate, this is not a Rakudo regression, so it can be eliminated as a blocker.

@jnthn
Copy link
Member

jnthn commented May 3, 2019

Part of the confusion is the original post in this issue has the wrong URL; it should be the one in this commit to try to reproduce the bug.

I've tried it with something close to Rakudo HEAD and I didn't see the issue. Tried various spesh flags to provoke optimizer bugs; no luck there either. Ran it 100 times in a loop both inside the program and with 100 perl6 invocations too; again, no joy. Either it's fixed by something, or it's good at hiding.

@JJ
Copy link
Collaborator

JJ commented May 3, 2019

@jnthn I don't think it makes a difference. It should be fixed with my patch to HTTP::UserAgent. I can add that test to WWW if you want.

@kawaii kawaii removed the BLOCKER Preventing the next release of rakudo, or just needing attention before the release label May 3, 2019
@gfldex
Copy link
Contributor Author

gfldex commented May 13, 2019

I may have found another way to trigger this odd bug.

git clone https://github.com/gfldex/perl6-nonillist.git; perl6 -Iperl6-nonillist/lib/ perl6-nonillist/t/02-warn.t

yields:

===SORRY!===
No lexical found with name '$_'

jnthn added a commit that referenced this issue May 14, 2019
This situation could occur in the case of a begin-time EVAL that had a
code expression that contained an immediate QAST block. This led to the
failed $_ lookup reported in #2779, meaning that compilation of that
module no longer fails. Unfortunately, that isn't enough to make it
actually work, but it's a step closer.
@jnthn
Copy link
Member

jnthn commented May 14, 2019

I don't think this NoNilList thing here is the same thing. I've taken a look into it. The heart of the matter is this:

sub EXPORT($_?) {
    given $_ {
        when 'Warning' {
            EVAL ‚use MONKEY-TYPING; augment class Nil {
                method list() {
                    note 'Trying to turn Nil into a list.';
                    note Backtrace.new.list.tail.Str;
                    Empty
                }
            }‘;

        }
        when 'Fatal' {
            EVAL ‚use MONKEY-TYPING; augment class Nil {
               method list() {
                   X::TypeCheck::NilToList.new().fail();
               }
            }‘;
        }
        default {
            die 'Please use NoNilList::Warning or NoNilList::Fatal.';
        }
    }
  %()
}

First, why EVAL and not just use the MOP? But OK, it should still work. It turns out that in BEGIN-time mode, when we EVAL, we compile code immediately. I think that was to address an earlier issue, and it probably makes some sense. Unfortunately, since we compile everything, then we'd also end up compiling immediate blocks, and then executing them rather than just producing them. I addressed that in b9f8995. Now the error is:

Too many positionals passed; expected 0 arguments but got 1
   at <unknown>:1  (/home/jnthn/dev/perl6-nonillist/lib/.precomp/F0410381E8657AD8BB8FAA6C55BB868DE9B158DB/A2/A27A785FBAA3C9C57ADFA999D72B40C0DEDA55A8:<dependencies+deserialize>)
 from t/02-warn.t:16  (<ephemeral file>:<unit>)
 from t/02-warn.t:1  (<ephemeral file>:<unit-outer>)

It seems that somehow, the <dependencies+deserialize> block is ending up being installed in the Nil.list method instead of the intended one:

$ perl6 -Ilib -e 'use NoNilList::Warning; dd Nil.^find_method("list")'
Method <dependencies+deserialize> = method <dependencies+deserialize> (Nil: *%_) { #`(Method|66502368) ... }

Which is, well, oops.

@JJ
Copy link
Collaborator

JJ commented May 14, 2019 via email

@jnthn
Copy link
Member

jnthn commented May 14, 2019

@niner Don't suppose you have any guesses? I'm wondering if it's some kind of cuid conflict or some such, but if beats me where...

@niner
Copy link
Collaborator

niner commented May 14, 2019

Not yet a guess, but an even smaller example of where it's going wrong:

nine@sunshine:~/test/precomp9> cat A.pm 
unit module A;
BEGIN our &foo is export = EVAL 'sub foo($f) { note("foo $f") }';
nine@sunshine:~/test/precomp9> perl6 -I. -e 'use A; say &foo.signature; foo(1)'
($f)
Too many positionals passed; expected 0 arguments but got 1
  in sub  at /home/nine/test/precomp9/A.pm (A) line 1
  in block <unit> at -e line 1

And a different error when there's no argument:

nine@sunshine:~/test/precomp9> cat A.pm 
unit module A;
BEGIN our &foo is export = EVAL 'sub foo() { note("foo") }';
nine@sunshine:~/test/precomp9> perl6 -I. -e 'use A; say &foo.signature; foo()'
()
Void return not allowed to context requiring a return value
  in sub  at /home/nine/test/precomp9/A.pm (A) line 2

Seems like the sub's code obj definitely ends up in the wrong place when we compile it in a BEGIN time EVAL. FWIW this is certainly not the only BEGIN time EVAL issue left and I'm sure I didn't think about code objects in the EVALed code when I fixed it up to at least work somehow. So there may be some hidden and wrong assumptions about the "current block"

@gfldex
Copy link
Contributor Author

gfldex commented May 14, 2019

Fwiw I got the augment in my module running by adding an ENTER phaser in the when block. That breaks something else tho.

@gfldex
Copy link
Contributor Author

gfldex commented May 12, 2020

This bug got magically fixed quite some commits ago.

@lizmat lizmat closed this as completed May 12, 2020
@niner
Copy link
Collaborator

niner commented May 12, 2020

I don't think the bug is really gone away. The reduced test case still behaves the same:

nine@sunshine:~/test/precomp9> perl6 -I. -e 'use A; say &foo.signature; foo(1)'
===SORRY!=== Error while compiling -e
Calling foo(Int) will never work with declared signature ()
at -e:1
------> use A; say &foo.signature; ⏏foo(1)
nine@sunshine:~/test/precomp9> perl6 -I. -e 'use A; say &foo.signature; foo()'
()
Void return not allowed to context requiring a return value
  in sub foo at /home/nine/test/precomp9/A.pm (A) line 2
  in block <unit> at -e line 1

nine@sunshine:~/test/precomp9> rakudo -v
This is Rakudo version 2020.05.1-72-g85fa569ce built on MoarVM version 2020.05-10-g5fe4a8114

@niner niner reopened this May 12, 2020
@JJ JJ changed the title Regression in WWW "Calling x will never work with the declared signature" error when EVAL is done in a BEGIN block May 12, 2020
@MasterDuke17
Copy link
Contributor

I thought eeb4f43f87 might have made a difference, but it doesn't, I get the exact same output.

@MasterDuke17
Copy link
Contributor

Now there's a new error:

[dan@alexandria A]$ cat A.rakumod 
unit module A;
BEGIN our &foo is export = EVAL 'sub foo() { note("foo") }';
[dan@alexandria A]$ raku -I . -e 'use A; say &foo.signature; foo()'
()
Cannot invoke this object (REPR: Null; VMNull)
  in sub foo at EVAL_0 line 1
  in block <unit> at -e line 1

[dan@alexandria A]$ 

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

9 participants