Ticket #1307 (closed bug: fixed)

Opened 12 years ago

Last modified 12 years ago

NQP-rx doesn't handle comments correctly?

Reported by: Austin_Hastings Owned by: pmichaud
Priority: normal Milestone:
Component: nqp Version: 1.8.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

The code below, compiled via "parrot-nqp bad.nqp", fails. Moving the line comment # Subs carry their name to a separate line causes the parse to succeed.

module Foo;

sub inject_symbol($object, :$namespace, :$as?, :$force?) {
# Injects a PMC C< $object > into a C< $namespace >, optionally C< $as > a certain name. For C< Sub > and 
# C< MultiSub > PMCs, the name is not a requirement since they know their own names. For other PMC types,
# including injecting variable rather than functions, the C< $as > name must be provided by the caller. If 
# C< $force > is specified, any pre-existing symbol is overwritten. Otherwise, if a name collision occurs
# FIXME: an exception should be thrown, but currently isn't.

        unless Opcode::defined($as) { $as := ~ $object; } # Subs carry their name

        if !Opcode::isa($namespace, 'NameSpace') {
                $namespace := Opcode::get_hll_namespace($namespace);
        }

        # NB: find_var searches for *anything*, while find_sub requires isa(sub). In this case,
        # any collision is bad.
        if !$force && Opcode::defined($namespace.find_var($as)) {
                return 0;
        }

        $namespace.add_var($as, $object);
}

Change History

Changed 12 years ago by pmichaud

Now fixed in r42565.

Pm

Changed 12 years ago by pmichaud

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.