Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created July 6, 2011 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadzik/1067686 to your computer and use it in GitHub Desktop.
Save tadzik/1067686 to your computer and use it in GitHub Desktop.
SymbolTable bug?

Given the code:

method pod_block:sym<delimited>($/) {
    my $name := $*ST.add_constant('Str', 'str', $<type>.Str);
    my $past := $*ST.add_constant(
        'Pod__Block__Named', 'type_new',
        :name($name<compile_time_value>),
    );
    say("  The block from ",
        $/.from, "-", $/.to,
        " named '", $<type>.Str,
        "' became ", $past<compile_time_value>);
    make $past<compile_time_value>;
}

I get the output:

The block from 9-41 named 'pod' became Pod__Block__Named<16727264>
The block from 42-84 named 'otherpod' became Pod__Block__Named<16727264>

(Note the identical IDs)

Looks like add_constant is confused, and assumes the object are identical, thus serializing only the first one and then linking the other one to it. Note that it's a patched SymbolTable, commit https://github.com/rakudo/rakudo/commit/e258ef5a. I hope it's related to the patch and not to SymbolTable per se, but jnthn didn't notice anything broken in it (yet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment