-
Notifications
You must be signed in to change notification settings - Fork 559
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
... (yada-yada) parsing is inconsistent #16165
Comments
From @maukeCreated by @maukePerl parses '...' as 'die("Unimplemented")': $ perl -MO=Deparse -e '...' But it only does this at the beginning of a statement: $ perl -MO=Deparse -e '+ ...' However, '...' is not by itself a statement: $ perl -MO=Deparse -e '... sub foo {}' In fact, it's an expression: $ perl -MO=Deparse -e '... . "hello"' $ perl -MO=Deparse -e '... lt "hello"' $ perl -MO=Deparse -e '..., foo()' However, it's a naughty expression that doesn't tell the parser that the next $ perl -MO=Deparse -e '... + 0' Here '+ 0' is parsed as a unary + applied to 0. The syntax error occurs because This is especially noticeable with '/': $ perl -MO=Deparse -e '... / 1' $ perl -MO=Deparse -e '... / 1 /' For consistency, either '...' should be made a statement of its own, or it Perl Info
|
From @maukeOn Sat, 23 Sep 2017 04:39:49 -0700, mauke- wrote:
Patch (to do the latter) attached. Thoughts? |
From @mauke0001-parse-.-yadayada-as-a-term-not-an-operator-RT-132150.patchFrom 02be2fc4ff7e4ede46381ee96b533ffe1aaa50ab Mon Sep 17 00:00:00 2001
From: Lukas Mai <[email protected]>
Date: Sat, 23 Sep 2017 14:25:32 +0200
Subject: [PATCH] parse ... (yadayada) as a term, not an operator (RT #132150)
---
t/op/yadayada.t | 19 ++++++++++++++++++-
toke.c | 2 +-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git t/op/yadayada.t t/op/yadayada.t
index 861389f4c5..0013e37046 100644
--- t/op/yadayada.t
+++ t/op/yadayada.t
@@ -8,7 +8,7 @@ BEGIN {
use strict;
-plan 9;
+plan 12;
my $err;
my $err1 = "Unimplemented at $0 line ";
@@ -42,6 +42,23 @@ eval { @transformed = map {;... } @input; };
is $@, $err, "Disambiguation case 4";
$@ = '';
+
+note("RT #132150: ... is a term, not an operator");
+$err = $err1 . ( __LINE__ + 1 ) . $err2;
+eval { ... + 0 };
+is $@, $err, "... + 0 parses";
+$@ = '';
+
+$err = $err1 . ( __LINE__ + 1 ) . $err2;
+eval { ... % 1 };
+is $@, $err, "... % 1 parses";
+$@ = '';
+
+$err = $err1 . ( __LINE__ + 1 ) . $err2;
+eval { ... / 1 };
+is $@, $err, "... / 1 parses";
+$@ = '';
+
#
# Regression tests, making sure ... is still parsable as an operator.
#
diff --git toke.c toke.c
index a91a4fcfbe..63f8d418ca 100644
--- toke.c
+++ toke.c
@@ -6856,7 +6856,7 @@ Perl_yylex(pTHX)
}
if (PL_expect == XSTATE && s[1] == '.' && s[2] == '.') {
s += 3;
- OPERATOR(YADAYADA);
+ TERM(YADAYADA);
}
if (PL_expect == XOPERATOR || !isDIGIT(s[1])) {
char tmp = *s++;
--
2.14.1
|
From [email protected]l.mai@web.de wrote:
The current behaviour is indeed inconsistent, but the statement-like -zefram |
The RT System itself - Status changed from 'new' to 'open' |
From [email protected]l.mai@web.de via RT wrote:
perly.y makes clear that yada-yada is intended to be an expression, not -zefram |
From @SmylersZefram writes:
perlsyn documents it as being the ellipsis statement, specifically You can only use the elliptical statement to stand in for a complete These examples of attempts to use an ellipsis are syntax errors: use v5.12; print ...; Sounds like that is no longer true (and quite possibly that use of the Smylers |
From [email protected]Smylers wrote:
Hmm, that's an embuggerance. The bit you quoted about ambiguity with the Not only was PL_expect being set in a way hostile to treating "..." as a Taking into account the documentation and these additional implementation -zefram |
From [email protected]I wrote:
Looks like that works just fine. Only takes a small perly.y change Applied to blead as commit 29d69c3. I wasn't sure how to classify this for perldelta. On the one hand it's -zefram |
From @cpansproutOn Thu, 09 Nov 2017 17:06:43 -0800, zefram@fysh.org wrote:
Introducing a new term or prefix operator that looks like an existing infix breaks existing syntax, of the form: substr $x, 1, . substr $y, 1; (I write code like that all the time.) If you put ... instead of . then you have an example of code that a ... term will break. It doesn’t happen the other way round. We can introduce a new infix that looks like an existing prefix or term. -- Father Chrysostomos |
From @cpansproutOn Thu, 09 Nov 2017 18:27:24 -0800, zefram@fysh.org wrote:
I think that means this can be closed. I am doing that. -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release yesterday of Perl 5.28.0, this and 185 other issues have been Perl 5.28.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#132150 (status was 'resolved')
Searchable as RT132150$
The text was updated successfully, but these errors were encountered: