Open p5pRT opened 19 years ago
$ perl -le 'use constant NUMBERS => qw(one two three); print sort NUMBERS' NUMBERS
$ perl -le 'use constant NUMBERS => qw(one two three); print sort NUMBERS()'
$ perl -le 'use constant NUMBERS => qw(one two three); print sort (NUMBERS)' NUMBERS
$ perl -le 'use constant NUMBERS => qw(one two three); print sort (NUMBERS())' onethreetwo
(I imagine case #2 is related to ticket #30377.)
dcollins@nightshade64:\~/toolchain$ perl5.25.2 -MO=Deparse -le 'use constant NUMBERS => qw(one two three); print sort NUMBERS;' BEGIN { $/ = "\n"; $\ = "\n"; } use constant ('NUMBERS'\, ('one'\, 'two'\, 'three')); print sort('NUMBERS'); -e syntax OK dcollins@nightshade64:\~/toolchain$ perl5.25.2 -MO=Deparse -le 'use constant NUMBERS => qw(one two three); print sort NUMBERS();' BEGIN { $/ = "\n"; $\ = "\n"; } use constant ('NUMBERS'\, ('one'\, 'two'\, 'three')); print((sort NUMBERS ())); -e syntax OK dcollins@nightshade64:\~/toolchain$ perl5.25.2 -MO=Deparse -le 'use constant NUMBERS => qw(one two three); print sort (NUMBERS);' BEGIN { $/ = "\n"; $\ = "\n"; } use constant ('NUMBERS'\, ('one'\, 'two'\, 'three')); print sort('NUMBERS'); -e syntax OK dcollins@nightshade64:\~/toolchain$ perl5.25.2 -MO=Deparse -le 'use constant NUMBERS => qw(one two three); print sort (NUMBERS());' BEGIN { $/ = "\n"; $\ = "\n"; } use constant ('NUMBERS'\, ('one'\, 'two'\, 'three')); print sort(('one'\, 'two'\, 'three')); -e syntax OK
It's being interpreted as a bareword for some reason?
The RT System itself - Status changed from 'new' to 'open'
On Thu Jul 07 17:58:18 2016\, dcollinsn@gmail.com wrote:
It's being interpreted as a bareword for some reason?
Oh\, what fun! This is a very old bug. And it occurs because of the way that the parser gets to decide whether the first token after ‘sort’ is a comparison sub or part of the list to sort.
The lexer (toke.c) assumes that any word immediately following ‘sort’ is a comparison sub\, which gets emitted as a WORD token\, just like a bareword.
It is the parser (perly.y) that distinguishes between these two:
sort foo bar sort foo\,bar
So the lexer does not actually know at the time whether the word will be a comparator or not. That makes it hard to fix.
(All of this is from memory. I may be getting some of it wrong.)
use constant{Just=>another=>Perl=>hacker=>};$\="\,\n"; print join" "\,map eval"sort $_\,$_"\,qw! Just Perl!
--
Father Chrysostomos
Migrated from rt.perl.org#36333 (status was 'open')
Searchable as RT36333$