Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

some singleton Slips deparse incorrectly #4863

Open p6rt opened 8 years ago

p6rt commented 8 years ago

Migrated from rt.perl.org#126902 (status was 'new')

Searchable as RT126902$

p6rt commented 8 years ago

From zefram@fysh.org

The fix for [perl #​126897] assumes that a slip(...) constructor expression parses equivalently to (...) list construction, at least in cases where the expression in the parens does construct a list. This turns out not to be the case for some singleton lists, leading to some round-trip failures​:

([1,2],).Slip.perl slip([1, 2],) ([1,2],).Slip.perl.EVAL.perl slip(1, 2)

I think the array unwrapping when evaluating the slip([1,2],) expression is intentional, and thus the .perl method on Slip is erroneous in not taking account of that effect when generating a slip(...) expression. Incidentally, there's a related LTA​:

slip(2).perl slip(2,)

For list construction that comma is necessary, but it's not required (but is legal) in the slip() argument list. It would be preferable to omit it in this output.

A simple fix would be for the .perl method to postfix ".Slip" to the list constructor expression rather than prefix "slip". This would actually use the list constructor expression in its intended syntactic environment.

-zefram