Skip to content

Instantly share code, notes, and snippets.

@semifor
Created September 24, 2011 19:48
Show Gist options
  • Select an option

  • Save semifor/1239772 to your computer and use it in GitHub Desktop.

Select an option

Save semifor/1239772 to your computer and use it in GitHub Desktop.
Bareword disambiguation with + and ::
#!/usr/bin/env perl
use Test::More;
use O qw/-qq Deparse/;
package Foo;
sub Bar {}
package Foo::Bar;
sub new { bless {}, shift }
package Foo::Baz;
sub new { bless {}, shift }
package main;
isa_ok Foo::Bar->new, 'Foo::Bar'; # isa_ok Foo::Bar()->new, 'Foo::Bar'
isa_ok Foo::Bar::->new, 'Foo::Bar'; # 'Foo::Bar'->isa_ok->new, '???'
isa_ok +Foo::Bar->new, 'Foo::Bar'; # isa_ok Foo::Bar()->new, 'Foo::Bar'
isa_ok +Foo::Bar::->new, 'Foo::Bar'; # isa_ok 'Foo::Bar'->new, 'Foo::Bar'
isa_ok Foo::Baz->new, 'Foo::Baz'; # 'Foo::Baz'->isa_ok->new, '???'
isa_ok Foo::Baz::->new, 'Foo::Baz'; # 'Foo::Baz'->isa_ok->new, '???'
isa_ok +Foo::Baz->new, 'Foo::Baz'; # isa_ok 'Foo::Baz'->new, 'Foo::Baz'
isa_ok +Foo::Baz::->new, 'Foo::Baz'; # isa_ok 'Foo::Baz'->new, 'Foo::Baz'
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment