From 4edddfd850e02fc8395613f5c1befe48a96c8eb6 Mon Sep 17 00:00:00 2001 From: Tobias Leich Date: Mon, 3 Jun 2013 00:35:30 +0200 Subject: [PATCH] added "use vars" support, +128 passing tests --- STATUS.md | 256 +++++++++++++++++++++++++++++------------- lib/Perl5/Grammar.nqp | 38 +++++++ 2 files changed, 214 insertions(+), 80 deletions(-) diff --git a/STATUS.md b/STATUS.md index 27f5012..41c9161 100644 --- a/STATUS.md +++ b/STATUS.md @@ -3,7 +3,41 @@ passfailtodoskipspec - summary5563970563840302 + summary6843957763840302 + opbasic/arith.v51283900167 + use of uninitialized value of type Any in numeric context in sub infix:<+=> at lib/Perl5/Terms.pm:142 + +use of uninitialized value of type Any in numeric context in sub infix:<+=> at lib/Perl5/Terms.pm:142 + +use of uninitialized value of type Any in numeric context in sub infix:<+=> at lib/Perl5/Terms.pm:142 + +use of uninitialized value of type Any in numeric context in sub infix:<+=> at lib/Perl5/Terms.pm:142 + +use of uninitialized value of type Any in numeric context in sub infix:<+=> at lib/Perl5/Terms.pm:142 + +use of uninitialized value of type Any in numeric context in sub infix:<+=> at lib/Perl5/Terms.pm:142 + +use of uninitialized value of type Any in numeric context in sub infix:<-=> at lib/Perl5/Terms.pm:143 + +use of uninitialized value of type Any in numeric context in sub infix:<-=> at lib/Perl5/Terms.pm:143 + +use of uninitialized value of type Any in numeric context in sub infix:<-=> at lib/Perl5/Terms.pm:143 + +use of uninitialized value of type Any in numeric context in sub infix:<-=> at lib/Perl5/Terms.pm:143 + +use of uninitialized value of type Any in numeric context in sub infix:<-=> at lib/Perl5/Terms.pm:143 + +use of uninitialized value of type Any in numeric context in sub infix:<-=> at lib/Perl5/Terms.pm:143 + +Cannot convert string to number: radix point must be followed by one or more valid digits in '20.⏏' (indicated by ⏏) + in method Numeric at src/gen/CORE.setting:10063 + in sub infix: at src/gen/CORE.setting:2996 + in sub infix: at src/gen/CORE.setting:2993 + in sub infix: at src/gen/CORE.setting:2996 + in sub infix: at src/gen/CORE.setting:2993 + in block at t/spec/opbasic/arith.v5:294 + + op/list.v55770064 use of uninitialized value of type Any in string context in block at t/spec/op/list.v5:146 @@ -203,9 +237,9 @@ Could not find B::Deparse in any of: ., ../lib op/do.v500000 ===SORRY!=== -Missing block -at t/spec/op/do.v5:30 -------> $result = do ⏏foo1(1); +Two terms in a row +at t/spec/op/do.v5:73 +------> print $do ⏏"isnt(wantarray, undef, 'do in scalar co op/exists_sub.v500000 ===SORRY!=== Missing block @@ -244,7 +278,7 @@ Could not find Tie::Array in any of: /home/froggs/dev/nqp/install/lib/parrot/5.2 op/leaky-magic.v500000 ===SORRY!=== -Could not find tests in any of: ../lib +Could not find tests in any of: /home/froggs/dev/nqp/install/lib/parrot/5.2.0-devel/languages/perl6/lib/Perl5 op/my.v500000 ===SORRY!=== @@ -263,8 +297,9 @@ at t/spec/comp/line_debug.v5:36 op/readdir.v500000 ===SORRY!=== -Could not find vars in any of: /home/froggs/dev/nqp/install/lib/parrot/5.2.0-devel/languages/perl6/lib/Perl5 - +Variable '*OP' is not declared +at t/spec/op/readdir.v5:18 +------> local *OP⏏; op/require_37033.v500000 ===SORRY!=== Variable '%INC' is not declared @@ -281,7 +316,7 @@ at t/spec/op/require_37033.v5:13 op/smartkve.v500000 ===SORRY!=== -Could not find vars in any of: /home/froggs/dev/nqp/install/lib/parrot/5.2.0-devel/languages/perl6/lib/Perl5 +Could not find overload in any of: /home/froggs/dev/nqp/install/lib/parrot/5.2.0-devel/languages/perl6/lib/Perl5 op/splice.v500000 ===SORRY!=== @@ -535,34 +570,64 @@ quantifier quantifies nothing at t/spec/re/regex_sets.v5:23 ------> like("a", qr/(?⏏[ [a] # This is a comment re/regex_sets_compat.v500000 - ===SORRY!=== -Missing block -at t/spec/re/regex_sets_compat.v5:12 -------> do ⏏$file or die $@; + Null filename used + in sub _P5do at lib/Perl5/Terms.pm:169 + in block at t/spec/re/regex_sets_compat.v5:11 + in method reify at src/gen/CORE.setting:5775 + in method reify at src/gen/CORE.setting:5670 + in method gimme at src/gen/CORE.setting:6101 + in method eager at src/gen/CORE.setting:6080 + in block at t/spec/re/regex_sets_compat.v5:10 + + re/regexp.v500000 ===SORRY!=== Could not find warnings in any of: ../lib re/regexp_noamp.v500000 - ===SORRY!=== -Missing block -at t/spec/re/regexp_noamp.v5:9 -------> do ⏏$file or die $@; + Null filename used + in sub _P5do at lib/Perl5/Terms.pm:169 + in block at t/spec/re/regexp_noamp.v5:8 + in method reify at src/gen/CORE.setting:5775 + in method reify at src/gen/CORE.setting:5670 + in method gimme at src/gen/CORE.setting:6101 + in method eager at src/gen/CORE.setting:6080 + in block at t/spec/re/regexp_noamp.v5:7 + + re/regexp_notrie.v500000 - ===SORRY!=== -Missing block -at t/spec/re/regexp_notrie.v5:12 -------> do ⏏$file or die $@; + Null filename used + in sub _P5do at lib/Perl5/Terms.pm:169 + in block at t/spec/re/regexp_notrie.v5:11 + in method reify at src/gen/CORE.setting:5775 + in method reify at src/gen/CORE.setting:5670 + in method gimme at src/gen/CORE.setting:6101 + in method eager at src/gen/CORE.setting:6080 + in block at t/spec/re/regexp_notrie.v5:10 + + re/regexp_qr.v500000 - ===SORRY!=== -Missing block -at t/spec/re/regexp_qr.v5:7 -------> do ⏏$file or die $@; + Null filename used + in sub _P5do at lib/Perl5/Terms.pm:169 + in block at t/spec/re/regexp_qr.v5:6 + in method reify at src/gen/CORE.setting:5775 + in method reify at src/gen/CORE.setting:5670 + in method gimme at src/gen/CORE.setting:6101 + in method eager at src/gen/CORE.setting:6080 + in block at t/spec/re/regexp_qr.v5:5 + + re/regexp_qr_embed.v500000 - ===SORRY!=== -Missing block -at t/spec/re/regexp_qr_embed.v5:8 -------> do ⏏$file or die $@; + Null filename used + in sub _P5do at lib/Perl5/Terms.pm:169 + in block at t/spec/re/regexp_qr_embed.v5:7 + in method reify at src/gen/CORE.setting:5775 + in method reify at src/gen/CORE.setting:5670 + in method gimme at src/gen/CORE.setting:6101 + in method eager at src/gen/CORE.setting:6080 + in block at t/spec/re/regexp_qr_embed.v5:6 + + re/regexp_qr_embed_thr.v500000 No such symbol '&useithreads' in method at src/gen/CORE.setting:10070 @@ -573,10 +638,16 @@ at t/spec/re/regexp_qr_embed.v5:8 re/regexp_trielist.v500000 - ===SORRY!=== -Missing block -at t/spec/re/regexp_trielist.v5:12 -------> do ⏏$file or die $@; + Null filename used + in sub _P5do at lib/Perl5/Terms.pm:169 + in block at t/spec/re/regexp_trielist.v5:12 + in method reify at src/gen/CORE.setting:5775 + in method reify at src/gen/CORE.setting:5670 + in method gimme at src/gen/CORE.setting:6101 + in method eager at src/gen/CORE.setting:6080 + in block at t/spec/re/regexp_trielist.v5:11 + + re/regexp_unicode_prop.v500000 ===SORRY!=== Missing block @@ -589,25 +660,22 @@ at t/spec/re/regexp_unicode_prop.v5:17 re/substT.v500000 - ===SORRY!=== -Missing block -at t/spec/re/substT.v5:6 -------> do ⏏"./$file"; + Unable to open filehandle from path './': No such file or directory(2) in block at lib/Perl5/Terms.pm:163 + + re/subst_amp.v500000 ===SORRY!=== Unrecognized Perl 5 regex backslash sequence at t/spec/re/subst_amp.v5:22 ------> s/\⏏Ga(?{push @res, $_, $`})/xx/g; re/subst_wamp.v500000 - ===SORRY!=== -Missing block -at t/spec/re/subst_wamp.v5:7 -------> do ⏏"./$file"; + Unable to open filehandle from path './': No such file or directory(2) in block at lib/Perl5/Terms.pm:163 + + re/uniprops.v500000 - ===SORRY!=== -Missing block -at t/spec/re/uniprops.v5:8 -------> do ⏏'../lib/unicore/TestProp.pl'; + WARNINGS: +Useless use of constant integer 0 in sink context (line 10) + run/exit.v500000 WARNINGS: Useless use of "," in expression "my $exit, $exit_arg" in sink context (line 49) @@ -668,10 +736,10 @@ No such symbol '&tempfile' Could not locate compile-time value for symbol pass io/crlf_through.v500000 - ===SORRY!=== -Missing block -at t/spec/io/crlf_through.v5:11 -------> do ⏏'./io/through.t' or die "no kid script"; + no kid script + in block at t/spec/io/crlf_through.v5:11 + + uni/fold.v500000 Error while reading from file: Invalid character in UTF-8 string @@ -1151,7 +1219,7 @@ No such symbol '&skip_all_without_config' op/utftaint.v503003 ===SORRY!=== -Placeholder variable H^ash[0x122cc7c8] may not be used here because the surrounding block takes no signature +Placeholder variable H^ash[0x115e77c0] may not be used here because the surrounding block takes no signature at t/spec/op/utftaint.v5:15 ------> not eval { join("",@_), kill 0; 1 }⏏; run/noswitch.v503003 @@ -1850,8 +1918,9 @@ at t/spec/mro/next_edgecases_utf8.v5:27 op/protowarn.v50120012 ===SORRY!=== -Could not find vars in any of: /home/froggs/dev/nqp/install/lib/parrot/5.2.0-devel/languages/perl6/lib/Perl5 - +Variable '%SIG' is not declared +at t/spec/op/protowarn.v5:35 +------> $SIG{'__WARN__'}⏏ = sub { push @warnings, @_ }; io/dup.v50120012 ===SORRY!=== Preceding context expects a term, but found infix < instead @@ -1898,11 +1967,7 @@ at t/spec/op/wantarray.v5:15 Unrecognized Perl 5 regex backslash sequence at t/spec/run/switchC.v5:27 ------> like( $r, qr/^$b(?:\⏏r?\n)?$/s, '-CO: no warning on UTF-8 out - run/switcht.v50130013 - ===SORRY!=== -Missing block -at t/spec/run/switcht.v5:58 -------> $test = do ⏏'.\ttdir/ttest.pl'; + run/switcht.v50130013 lib/universal.v50130013 ===SORRY!=== Preceding context expects a term, but found infix << instead @@ -1979,8 +2044,9 @@ Could not find file './test.pl' for module ./test.pl op/hashwarn.v50160016 ===SORRY!=== -Could not find vars in any of: /home/froggs/dev/nqp/install/lib/parrot/5.2.0-devel/languages/perl6/lib/Perl5 - +Variable '%SIG' is not declared +at t/spec/op/hashwarn.v5:18 +------> $SIG{'__WARN__'}⏏ = sub { push @warnings, @_ }; op/push.v50160016 ===SORRY!=== Preceding context expects a term, but found infix << instead @@ -2321,8 +2387,15 @@ Confused at t/spec/op/repeat.v5:130 ------> my ($x, $y) = scalar ((1,2)x⏏2); op/study.v50430043 - ===SORRY!=== -Could not find vars in any of: ../lib + ===SORRY!=== +Couldn't find terminator | +at t/spec/op/study.v5:69 +------> ok(m|bc/*d|#); + expecting any of: + argument list + standard stopper + argument + prefix or term comp/uproto.v50430043 ===SORRY!=== @@ -2425,8 +2498,13 @@ at t/spec/op/grep.v5:57 Could not locate compile-time value for symbol is op/each_array.v50630063 - ===SORRY!=== -Could not find vars in any of: /home/froggs/dev/nqp/install/lib/parrot/5.2.0-devel/languages/perl6/lib/Perl5 + No such symbol '&each' + in method at src/gen/CORE.setting:10070 + in any at src/gen/Metamodel.nqp:2504 + in any find_method_fallback at src/gen/Metamodel.nqp:2492 + in any find_method at src/gen/Metamodel.nqp:939 + in block at t/spec/op/each_array.v5:17 + op/tiehandle.v50630063 ===SORRY!=== @@ -2446,7 +2524,7 @@ at t/spec/op/localref.v5:20 at t/spec/op/loopctl.v5:964 ------> for ($i = 1; my $x ⏏= $i; ) { ===SORRY!=== -Could not find sub cuid_97_1369922638.43936 +Could not find sub cuid_97_1370211556.01168 op/time.v50660066 No such symbol '&watchdog' @@ -2458,10 +2536,30 @@ Could not find sub cuid_97_1369922638.43936 op/tiearray.v50690069 - ===SORRY!=== -Missing block -at t/spec/op/tiearray.v5:252 -------> do ⏏'/dev/null'; + Potential difficulties: + Redeclaration of symbol @dummy + at t/spec/op/tiearray.v5:295 + ------> tie my @dummy⏏, "NegFetchsize"; +No such symbol '&tie' + in method at src/gen/CORE.setting:10070 + in any at src/gen/Metamodel.nqp:2504 + in any find_method_fallback at src/gen/Metamodel.nqp:2492 + in any find_method at src/gen/Metamodel.nqp:939 + in block at t/spec/op/tiearray.v5:155 + in method reify at src/gen/CORE.setting:5775 + in method reify at src/gen/CORE.setting:5670 + in method gimme at src/gen/CORE.setting:6101 + in method sink at src/gen/CORE.setting:6402 + in block at t/spec/op/tiearray.v5:153 + in method reify at src/gen/CORE.setting:5775 + in method reify at src/gen/CORE.setting:5670 + in method gimme at src/gen/CORE.setting:6101 + in method sink at src/gen/CORE.setting:6402 + in block at t/spec/op/tiearray.v5:151 + in block at t/spec/op/tiearray.v5:107 + in block at t/spec/op/tiearray.v5:1 + + uni/greek.v50720072 Error while reading from file: Malformed UTF-8 string @@ -2492,8 +2590,9 @@ at t/spec/base/lex.v5:407 ------> op/undef.v50850085 ===SORRY!=== -Could not find vars in any of: ../lib - +Variable '$a' is not declared +at t/spec/op/undef.v5:16 +------> ok !defined($a⏏); op/goto.v50890089 ===SORRY!=== Variable '%SIG' is not declared @@ -2562,18 +2661,18 @@ at t/spec/io/open.v5:27 ------> ok( (print $f ⏏"SomeData\n"), ' we can print to op/array.v5012700127 ===SORRY!=== -Could not find vars in any of: ., ../lib +Could not locate compile-time value for symbol is cmd/lexsub.v5012800128 ===SORRY!=== Missing block -at t/spec/cmd/lexsub.v5:34 -------> is do ⏏foo(), 42, 'calling our sub from same pa +at t/spec/cmd/lexsub.v5:59 +------> our sub b⏏; op/eval.v5012800128 ===SORRY!=== Missing block -at t/spec/op/eval.v5:52 -------> do ⏏"./$tempfile"; print $@; +at t/spec/op/eval.v5:92 +------> is(eval⏏('"$b"'), $b); op/lc.v5012800128 Error while reading from file: Malformed UTF-8 string @@ -2620,10 +2719,6 @@ at t/spec/op/split_unicode.v5:28 Unrecognized backslash sequence: '\Q' at t/spec/comp/parser.v5:115 ------> is( "\⏏Q\Q\Q\Q\Q\Q\Q\Q\Q\Q\Q\Q\Qa", "a", "PL_le - opbasic/arith.v5016700167 - ===SORRY!=== -Could not find vars in any of: ../lib - op/bop.v5017400174 ===SORRY!=== Unable to parse expression in argument list; couldn't find final ')' @@ -2717,8 +2812,9 @@ at t/spec/re/pat.v5:12 ------> sub run_tests⏏; op/taint.v5079700797 ===SORRY!=== -Could not find vars in any of: /home/froggs/dev/nqp/install/lib/parrot/5.2.0-devel/languages/perl6/lib/Perl5 - +Two terms in a row +at t/spec/op/taint.v5:41 +------> IPC::SysV->import(⏏qw(IPC_PRIVATE IPC_RMID IPC_CREAT S_IRWX op/sprintf2.v501370001370 ===SORRY!=== Variable '$i' is not declared diff --git a/lib/Perl5/Grammar.nqp b/lib/Perl5/Grammar.nqp index f91d2cb..fbf1aeb 100644 --- a/lib/Perl5/Grammar.nqp +++ b/lib/Perl5/Grammar.nqp @@ -1398,6 +1398,44 @@ grammar Perl5::Grammar is HLL::Grammar does STD5 { || [ [0] eq '6' }> { $*MAIN := 'MAIN'; } ]? + || 'vars' <.ws>? + { + my $vars := $*W.compile_time_evaluate($/, $.ast); + $vars := nqp::getattr($vars.list.eager, + $*W.find_symbol(['List']), '$!items'); + my $*IN_DECL := 'variable'; + my $*SCOPE := 'our'; + for $vars { + my $name := $_; + my $sigil := nqp::substr($name, 0, 1); + my $varast := QAST::Var.new( :name($name), :node($/), :scope ); + my $BLOCK := $*W.cur_lexpad(); + + # Create a container descriptor. Default to rw and set a + # type if we have one; a trait may twiddle with that later. + my %cont_info := $*W.container_type_info($/, $sigil, []); + my $descriptor := $*W.create_container_descriptor(%cont_info, 1, $name); + + $*W.install_lexical_container($BLOCK, $name, %cont_info, $descriptor, + :scope('our'), :package($*PACKAGE)); + + # Set scope and type on container, and if needed emit code to + # reify a generic type. + $varast.returns(%cont_info); + if %cont_info.HOW.archetypes.generic { + $varast := QAST::Op.new( + :op('callmethod'), :name('instantiate_generic'), + QAST::Op.new( :op('p6var'), $varast ), + QAST::Op.new( :op('curlexpad') )); + } + + $BLOCK[0].push(QAST::Op.new( + :op('bind'), + $varast, + $*W.symbol_lookup([$name], $/, :package_only(1), :lvalue(1)) + )); + } + } || ? [ <.spacey> [0] }> ]? {