Ticket #173 (closed bug: invalid)

Opened 6 years ago

Last modified 4 years ago

lexicals not found in PIRC

Reported by: kjs Owned by: kjs
Priority: normal Milestone:
Component: core Version:
Severity: medium Keywords: lexicals
Cc: parrot-dev@… Language:
Patch status: Platform:

Description (last modified by pmichaud) (diff)

lexicals can't be found in nested .subs. the following works in parrot, but the generated bytecode doesn't seem to work:

.sub main
 .lex "x", $P0
 $P0 = new "Integer"
 $P0 = 42
 foo()
.end

.sub foo :outer("main")
 $P0 = find_lex "x"
 print $P0
.end

So, apparently, lexicals are not stored correctly. This needs fixing.

Change History

  Changed 6 years ago by kjs

  • description modified (diff)

  Changed 4 years ago by plobsing

  • description modified (diff)

  Changed 4 years ago by plobsing

  • description modified (diff)

This issue is now being tracked at as issue #9 for  https://github.com/parrot/pirc. ( https://github.com/parrot/pirc/issues/#issue/9)

  Changed 4 years ago by plobsing

  • description modified (diff)

  Changed 4 years ago by plobsing

  • status changed from new to closed
  • resolution set to wontfix
  • description modified (diff)

  Changed 4 years ago by bacek

  • status changed from closed to reopened
  • component changed from pirc to core
  • resolution wontfix deleted
  • description modified (diff)

Hello.

It's not pirc bug. IMCC-generated PBC has same problem.

-- Bacek

follow-up: ↓ 8   Changed 4 years ago by bacek

  • description modified (diff)

This is output of sample from description.

~/src/parrot (master)$ ./parrot lex.pir 
42
~/src/parrot (master)$ ./parrot -o lex.pbc lex.pir 
~/src/parrot (master)$ ./parrot lex.pbc 
Null PMC in say
current instr.: 'foo' pc 21 (lex.pir:10)
called from Sub 'main' pc 13 (lex.pir:5)

-- Bacek.

in reply to: ↑ 7   Changed 4 years ago by pmichaud

  • description modified (diff)

Note that the original code is missing a "capture_lex" instruction required for lexical capture. Correct code should be:

$ cat lex.pir
.sub main
    .const 'Sub' foosub = 'foo'
    capture_lex foosub
    .lex "x", $P0
    $P0 = new "Integer"
    $P0 = 42
    foo()
.end

.sub foo :outer("main")
    $P0 = find_lex "x"
    say $P0
.end
$ ./parrot lex.pir
42
$ ./parrot -o lex.pbc lex.pir
$ ./parrot lex.pbc
42
$ 

Pm

  Changed 4 years ago by bacek

  • status changed from reopened to closed
  • resolution set to invalid

Based on pmichauds comment mark ticket as invalid.

Note: See TracTickets for help on using tickets.