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

Named enums don't work correctly with a quoted list #3582

Open
p6rt opened this issue Nov 12, 2014 · 3 comments
Open

Named enums don't work correctly with a quoted list #3582

p6rt opened this issue Nov 12, 2014 · 3 comments

Comments

@p6rt
Copy link

p6rt commented Nov 12, 2014

Migrated from rt.perl.org#123191 (status was 'open')

Searchable as RT123191$

@p6rt
Copy link
Author

p6rt commented Nov 12, 2014

From @b2gills

  enum Phonetic ( :Alpha<A>, <Beta Charlie> );
  say Phonetic.enums; # "Alpha" => "A", "Beta Charlie" => "B"

I believe I have localized the problem to the line (3297) in src/Perl6/Actions.nqp that I have commented out below.
The lines I have replaced it with make it work for the test case above.
( Of course it isn't general enough )
I don't know enough NQP to properly fix it myself.

  if $term_ast.isa(QAST​::Op) && $term_ast.name eq '&infix​:<,>' {
  for @​($term_ast) {
  if istype($_.returns(), $Pair) && $_[1].has_compile_time_value {
  @​values.push($_);
  }
  elsif $_.has_compile_time_value {
  @​values.push($_);
  }
  else {
  # @​values.push($*W.compile_time_evaluate($&lt;term>, $_));
  @​values.push( $_[0][0] ); # <====
  @​values.push( $_[0][1] ); # <====
  }
  }
  }

@p6rt
Copy link
Author

p6rt commented Aug 30, 2016

From @skids

This report predates the GLR where flattening behavior changed.

Under GLR rules you'd have to flatten the quoted list. However, it appears
flattening directly inside the enum arglist is broken​:

$ perl6 -e 'enum Phonetic ( :Alpha<A>, |<Beta Charlie> ); say Phonetic.enums'
Map.new((​:Alpha("A"),"Beta Charlie" => "B"))
$ perl6 -e 'enum Phonetic ( :Alpha<A>, |("Beta", "Charlie") ); say Phonetic.enums'
Map.new((​:Alpha("A"),"Beta Charlie" => "B"))
# Due to a different RT this workaround doesn't work around unfortunately
$ perl6 -e 'enum Phonetic (( :Alpha<A>, |("Beta", "Charlie") )); say Phonetic.enums'
Map.new(("Alpha\tA" => 0,​:Beta(1),​:Charlie(2)))
$ perl6 -e 'enum Phonetic (( :Alpha<A>, |<Beta Charlie> )); say Phonetic.enums'
Map.new(("Alpha\tA" => 0,​:Beta(1),​:Charlie(2)))

Maybe repurpose this RT as "flattening/slips ignored inside enum value list"

@p6rt
Copy link
Author

p6rt commented Aug 30, 2016

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

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