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

Some item assignments inside comma-separated lists are parsed with too loose precedence #4326

Closed
p6rt opened this issue Jun 15, 2015 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jun 15, 2015

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

Searchable as RT125416$

@p6rt
Copy link
Author

p6rt commented Jun 15, 2015

From @smls

An item assignment inside a comma-separated list works as expected as long as the preceding element is a literal​:

  ➜ dd 1, my $x = 2, 3
  1
  $x = 2
  3

However when the preceding element is a sub or method call, the assignment for some reason gobbles the whole remaining list (as if it were a list assignment)​:

  ➜ dd Int(1), my $x = 2, 3
  1
  $x = $(2, 3)

  ➜ dd 1.Int, my $x = 2, 3
  1
  $x = $(2, 3)

I would assume this is a bug.

Unfortunately, http://design.perl6.org/S03.html#List_prefix_precedence does not go into details on how exactly the LHS of an assignment is supposed to determine item vs list precedence though.

@p6rt
Copy link
Author

p6rt commented Jun 21, 2015

From @jnthn

On Mon Jun 15 16​:22​:00 2015, smls75@​gmail.com wrote​:

An item assignment inside a comma-separated list works as expected as
long as the preceding element is a literal​:

➜ dd 1, my $x = 2, 3
1
$x = 2
3

However when the preceding element is a sub or method call, the
assignment for some reason gobbles the whole remaining list (as if it
were a list assignment)​:

➜ dd Int(1), my $x = 2, 3
1
$x = $(2, 3)

➜ dd 1.Int, my $x = 2, 3
1
$x = $(2, 3)

I would assume this is a bug.

Unfortunately, http://design.perl6.org/S03.html#List_prefix_precedence
does not go into details on how exactly the LHS of an assignment is
supposed to determine item vs list precedence though.

We didn't declare a fresh $*LEFTSIGIL per declarator, so we could end up with a postfix elsewhere "leaking" into the decision making. Fixed that now, and added a test in S03-operators/assignment.t.

@p6rt
Copy link
Author

p6rt commented Jun 21, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jun 21, 2015

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

@p6rt p6rt closed this as completed Jun 21, 2015
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