Ticket #900 (closed bug: fixed)

Opened 5 years ago

Last modified 4 years ago

NQP parses functions beginning with 'make' as keyword

Reported by: Austin_Hastings Owned by: pmichaud
Priority: normal Milestone:
Component: nqp Version: 1.4.0
Severity: medium Keywords: token, nqp, make, keyword
Cc: Language:
Patch status: Platform:

Description

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.

Change History

Changed 4 years ago by coke

  • status changed from new to closed
  • resolution set to fixed

This doesn't appear to be an issue in nqprx (and the old nqp is gone.)

Note: See TracTickets for help on using tickets.