Ticket #1514 (closed bug: invalid)

Opened 5 years ago

Last modified 3 years ago

NQP-rx doesn't check storage mode for contextuals

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

Description

Reading from a contextual ($*foo) variable checks for a dynamic lexical, and if none is found tries reading from a global in the HLL-root namespace.

Storing, however, does not check, and so an attempt to store to $*foo will die if no dynamic lexical is found with the right name - storing to the global is never considered.

$*foo := 1;
say($*foo);

produces this code:

.annotate "line", 1
    new $P13, "Integer"
    assign $P13, 1
    store_dynamic_lex "$*foo", $P13
.annotate "line", 3
    find_dynamic_lex $P14, "$*foo"
    unless_null $P14, vivify_11
    get_hll_global $P14, "$foo"
    unless_null $P14, vivify_12
    die "Contextual $*foo not found"

Change History

Changed 3 years ago by pmichaud

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

This is correct behavior for nqp-rx; one is not allowed to rebind globals through the dynamic variable interface. (I'm amenable to changing this if we come up with strong reasons for it.)

Pm

Note: See TracTickets for help on using tickets.