Ticket #500 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

:init sub cannot be target of :outer

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

Description

(This ticket was originally RT #47956)

Currently the PIR compiler cannot handle :outer flags pointing to a Sub with the :init flag on it.

Running from the command line works:

$ cat x.pir
.sub 'MAIN'
    say 'MAIN'
    .return ()
.end

.namespace ['XYZ']

.sub 'BEGIN' :init
    say 'XYZ::BEGIN'
    .return ()
.end

.sub 'foo' :outer('BEGIN')
    say 'XYZ::foo'
    .return ()
.end
$ ./parrot x.pir
XYZ::BEGIN
MAIN
$

Loading the text into a string and compiling that (via "compreg PIR") fails:

$ ./parrot y.pir
compiler start
reading x.pir into $S0
.sub 'MAIN'
    say 'MAIN'
    .return ()
.end

.namespace ['XYZ']

.sub 'BEGIN' :init
    say 'XYZ::BEGIN'
    .return ()
.end

.sub 'foo' :outer('BEGIN')
    say 'XYZ::foo'
    .return ()
.end

compiling (but not running) $S0
XYZ::BEGIN
src/call/pcc.c:562: failed assertion '(sig_pmc)->vtable->base_type == enum_class_FixedIntegerArray'
Backtrace - Obtained 31 stack frames (max trace depth is 32).
  (unknown)
    Parrot_confess
      Parrot_init_arg_indexes_and_sig_pmc
        parrot_pass_args
          Parrot_Continuation_invoke
            Parrot_returncc
              (unknown)
                (unknown)
                  (unknown)
                    (unknown)
                      Parrot_runops_fromc_args
                        (unknown)
                          (unknown)
                            do_sub_pragmas
                              PackFile_fixup_subs
                                (unknown)
                                  (unknown)
                                    (unknown)
                                      Parrot_NCI_invoke
                                        Parrot_invokecc_p
                                          (unknown)
                                            (unknown)
                                              (unknown)
                                                (unknown)
                                                  Parrot_runops_fromc_args
                                                    Parrot_runcode
                                                      (unknown)
                                                        imcc_run
                                                          (unknown)
                                                            __libc_start_main
                                                              (unknown)
Aborted
$

(Note that it's the _compilation_ that fails.)

This ends up blocking a number of items in Rakudo -- most notably the ability for methods to access lexicals in an outer scope.

Pm

Change History

Changed 5 years ago by jkeenan

Whoever is looking at this TT should also glance at  this RT originally filed by Tene.

Changed 5 years ago by pmichaud

RT #58506 appears to have been resolved by the lexical changes performed last November (and I've now marked it as such). Thanks for catching that.

The original ticket (RT #47956) on which this ticket is based is still an issue, however.

Pm

Changed 5 years ago by jonathan

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

Fixed in r37872, and added something like the example on this ticket as a test in r37873.

Note: See TracTickets for help on using tickets.