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

pair with Nil key deparses incorrectly #4836

Closed
p6rt opened this issue Dec 13, 2015 · 7 comments
Closed

pair with Nil key deparses incorrectly #4836

p6rt opened this issue Dec 13, 2015 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Dec 13, 2015

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

Searchable as RT126890$

@p6rt
Copy link
Author

p6rt commented Dec 13, 2015

From zefram@fysh.org

$ perl6 -e '((Nil)=>1).key.WHAT.say; ((Nil)=>1).perl.EVAL.key.WHAT.say'
Nil
(Str)

The problem is that the .perl of that pair is "Nil => 1", which parses
as a string key rather than the Nil object. Parens or some other
circumlocution is required in order to preserve the meaning of "Nil"
in this context.

-zefram

@p6rt
Copy link
Author

p6rt commented Dec 13, 2015

From @lizmat

On 13 Dec 2015, at 05​:18, Zefram (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Zefram
# Please include the string​: [perl #​126890]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126890 >

$ perl6 -e '((Nil)=>1).key.WHAT.say; ((Nil)=>1).perl.EVAL.key.WHAT.say'
Nil
(Str)

The problem is that the .perl of that pair is "Nil => 1", which parses
as a string key rather than the Nil object. Parens or some other
circumlocution is required in order to preserve the meaning of "Nil"
in this context.

I think this is ENOTABUG.

Perl 6 has the same auto-quoting rules for the left side of a fat comma as Perl 5.

$ 6 'dd (Any => 42).key'
Str $var = “Any"

$ 6 'dd ((Any) => 42).key'
Any $var = Any

So, yes, you need to do something extra to keep the typedness of the left hand side. Just as you would need to do in Perl 5.

Another way of creating a Pair, is Pair.new​:

$ 6 'dd Pair.new(Any,42).key'
Any $var = Any

YMMV

Liz

@p6rt
Copy link
Author

p6rt commented Dec 13, 2015

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

@p6rt
Copy link
Author

p6rt commented Dec 13, 2015

From @timo

I think you might have misread the bug report.

This bug is about the .perl method on Pair not being careful enough if
the .perl of its .key looks like /<ident>/.

I am reluctant to add a full ~~ /<ident>/ to the .perl, as matching
carries quite a big overhead at the moment and that'd make printing a
list of pairs extra slow. Perhaps we could use "findnotcclass" to look
for non-alpha in the .perl and just throw parenthesis around it if
anything looks vaguely suspicious.

On 12/13/2015 11​:13 AM, Elizabeth Mattijsen wrote​:

On 13 Dec 2015, at 05​:18, Zefram (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Zefram
# Please include the string​: [perl #​126890]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126890 >

$ perl6 -e '((Nil)=>1).key.WHAT.say; ((Nil)=>1).perl.EVAL.key.WHAT.say'
Nil
(Str)

The problem is that the .perl of that pair is "Nil => 1", which parses
as a string key rather than the Nil object. Parens or some other
circumlocution is required in order to preserve the meaning of "Nil"
in this context.
I think this is ENOTABUG.

Perl 6 has the same auto-quoting rules for the left side of a fat comma as Perl 5.

$ 6 'dd (Any => 42).key'
Str $var = “Any"

$ 6 'dd ((Any) => 42).key'
Any $var = Any

So, yes, you need to do something extra to keep the typedness of the left hand side. Just as you would need to do in Perl 5.

Another way of creating a Pair, is Pair.new​:

$ 6 'dd Pair.new(Any,42).key'
Any $var = Any

YMMV

Liz

@p6rt
Copy link
Author

p6rt commented Dec 13, 2015

From @lizmat

Completely right!

5b6cbc7d54ce5ad252cf74 fixes Pair.perl properly.

Liz

On 13 Dec 2015, at 11​:16, Timo Paulssen <timo@​wakelift.de> wrote​:

I think you might have misread the bug report.

This bug is about the .perl method on Pair not being careful enough if
the .perl of its .key looks like /<ident>/.

I am reluctant to add a full ~~ /<ident>/ to the .perl, as matching
carries quite a big overhead at the moment and that'd make printing a
list of pairs extra slow. Perhaps we could use "findnotcclass" to look
for non-alpha in the .perl and just throw parenthesis around it if
anything looks vaguely suspicious.

On 12/13/2015 11​:13 AM, Elizabeth Mattijsen wrote​:

On 13 Dec 2015, at 05​:18, Zefram (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Zefram
# Please include the string​: [perl #​126890]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126890 >

$ perl6 -e '((Nil)=>1).key.WHAT.say; ((Nil)=>1).perl.EVAL.key.WHAT.say'
Nil
(Str)

The problem is that the .perl of that pair is "Nil => 1", which parses
as a string key rather than the Nil object. Parens or some other
circumlocution is required in order to preserve the meaning of "Nil"
in this context.
I think this is ENOTABUG.

Perl 6 has the same auto-quoting rules for the left side of a fat comma as Perl 5.

$ 6 'dd (Any => 42).key'
Str $var = “Any"

$ 6 'dd ((Any) => 42).key'
Any $var = Any

So, yes, you need to do something extra to keep the typedness of the left hand side. Just as you would need to do in Perl 5.

Another way of creating a Pair, is Pair.new​:

$ 6 'dd Pair.new(Any,42).key'
Any $var = Any

YMMV

Liz

@p6rt
Copy link
Author

p6rt commented Sep 18, 2017

From @skids

On Sun, 13 Dec 2015 06​:03​:35 -0800, elizabeth wrote​:

Completely right!

5b6cbc7d54ce5ad252cf74 fixes Pair.perl properly.

Liz

On 13 Dec 2015, at 11​:16, Timo Paulssen <timo@​wakelift.de> wrote​:

I think you might have misread the bug report.

This bug is about the .perl method on Pair not being careful enough
if
the .perl of its .key looks like /<ident>/.

I am reluctant to add a full ~~ /<ident>/ to the .perl, as matching
carries quite a big overhead at the moment and that'd make printing a
list of pairs extra slow. Perhaps we could use "findnotcclass" to
look
for non-alpha in the .perl and just throw parenthesis around it if
anything looks vaguely suspicious.

On 12/13/2015 11​:13 AM, Elizabeth Mattijsen wrote​:

On 13 Dec 2015, at 05​:18, Zefram (via RT) <perl6-bugs-
followup@​perl.org> wrote​:

# New Ticket Created by Zefram
# Please include the string​: [perl #​126890]
# in the subject line of all future correspondence about this
issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126890 >

$ perl6 -e '((Nil)=>1).key.WHAT.say;
((Nil)=>1).perl.EVAL.key.WHAT.say'
Nil
(Str)

The problem is that the .perl of that pair is "Nil => 1", which
parses
as a string key rather than the Nil object. Parens or some other
circumlocution is required in order to preserve the meaning of
"Nil"
in this context.
I think this is ENOTABUG.

Perl 6 has the same auto-quoting rules for the left side of a fat
comma as Perl 5.

$ 6 'dd (Any => 42).key'
Str $var = “Any"

$ 6 'dd ((Any) => 42).key'
Any $var = Any

So, yes, you need to do something extra to keep the typedness of the
left hand side. Just as you would need to do in Perl 5.

Another way of creating a Pair, is Pair.new​:

$ 6 'dd Pair.new(Any,42).key'
Any $var = Any

YMMV

Liz

Test added in roast commit 56ec03599, so resolving this ticket.

@p6rt p6rt closed this as completed Sep 18, 2017
@p6rt
Copy link
Author

p6rt commented Sep 18, 2017

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

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

1 participant