#900: NQP parses functions beginning with 'make' as keyword
-----------------------------+----------------------------------------------
 Reporter:  Austin_Hastings  |       Owner:  pmichaud                 
     Type:  bug              |      Status:  new                      
 Priority:  normal           |   Milestone:                           
Component:  nqp              |     Version:  1.4.0                    
 Severity:  medium           |    Keywords:  token, nqp, make, keyword
     Lang:                   |       Patch:                           
 Platform:                   |  
-----------------------------+----------------------------------------------
 The following code illustrates the problem:
 {{{
 # test.pm
 sub show_make_problem() {
         my $name := 'foo';
         my $type := 'foo';
         my $psym := 'foo';
         #my $bug :=
         make_new_symbol($name, $type, $psym);
 }
 }}}

 As it is, the 'make_new_symbol' is decomposed into 'make'  +
 '_new_symbol', and a reference to lexical '$/' is generated.
 Pir code:
 {{{
 .namespace []
 .sub "show_make_problem"  :subid("11_1249326619") :outer("10_1249326619")
 .annotate "line", 1
     new $P15, 'ExceptionHandler'
     set_addr $P15, control_14
     $P15."handle_types"(58)
     push_eh $P15
 .annotate "line", 2
     new $P16, "String"
     assign $P16, "foo"
     .lex "$name", $P16
 .annotate "line", 3
     new $P17, "String"
     assign $P17, "foo"
     .lex "$type", $P17
 .annotate "line", 4
     new $P18, "String"
     assign $P18, "foo"
     .lex "$psym", $P18
     find_lex $P19, "$/"                 #### Note $/ here
 .annotate "line", 6
     find_lex $P20, "$name"
     unless_null $P20, vivify_12
     new $P20, "Undef"
   vivify_12:
     find_lex $P21, "$type"
     unless_null $P21, vivify_13
     new $P21, "Undef"
   vivify_13:
     find_lex $P22, "$psym"
     unless_null $P22, vivify_14
     new $P22, "Undef"
   vivify_14:
     $P23 = "_new_symbol"($P20, $P21, $P22)  #### Note '_new_symbol'
     $P24 = $P19."!make"($P23)
 .annotate "line", 1
     .return ($P24)
   control_14:
     .local pmc exception
     .get_results (exception)
     getattribute $P25, exception, "payload"
     .return ($P25)
     rethrow exception
 .end
 }}}

 By uncommenting the `my $bug :=` line above, the output changes to:
 {{{
 .namespace []
 .sub "show_make_problem"  :subid("11_1249326898") :outer("10_1249326898")
 .annotate "line", 1
     new $P15, 'ExceptionHandler'
     set_addr $P15, control_14
     $P15."handle_types"(58)
     push_eh $P15
 .annotate "line", 2
     new $P16, "String"
     assign $P16, "foo"
     .lex "$name", $P16
 .annotate "line", 3
     new $P17, "String"
     assign $P17, "foo"
     .lex "$type", $P17
 .annotate "line", 4
     new $P18, "String"
     assign $P18, "foo"
     .lex "$psym", $P18
 .annotate "line", 6
     find_lex $P19, "$name"
     unless_null $P19, vivify_12
     new $P19, "Undef"
   vivify_12:
     find_lex $P20, "$type"
     unless_null $P20, vivify_13
     new $P20, "Undef"
   vivify_13:
     find_lex $P21, "$psym"
     unless_null $P21, vivify_14
     new $P21, "Undef"
   vivify_14:
     $P22 = "make_new_symbol"($P19, $P20, $P21)  #### Note correct name
     .lex "$bug", $P22
 .annotate "line", 1
     .return ($P22)
   control_14:
     .local pmc exception
     .get_results (exception)
     getattribute $P23, exception, "payload"
     .return ($P23)
     rethrow exception
 .end
 }}}

 Pretty clearly the NQP grammar needs a '>>' end-of-word marker after the
 'make' token.

 Inserting the nonsense assignment statement makes for an effective work-
 around.

-- 
Ticket URL: <https://trac.parrot.org/parrot/ticket/900>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets

Reply via email to