Skip to content

Instantly share code, notes, and snippets.

@softmoth
Last active December 12, 2017 00:59
Show Gist options
  • Save softmoth/c8e90a6e4eda72f732c9e49c5931e1b2 to your computer and use it in GitHub Desktop.
Save softmoth/c8e90a6e4eda72f732c9e49c5931e1b2 to your computer and use it in GitHub Desktop.
invalid typename or unknown type when nested under builtin type hierarchy

Save make-testcase.sh in /tmp, and:

rm -rf ./invalid-typename-bug; sh make-testcase.sh && \
    PERL6LIB=invalid-typename-bug/lib perl6 invalid-typename-bug/t.pl

If type=role, then the error is:

===SORRY!=== Error while compiling /tmp/invalid-typename-bug/lib/Bar.pm (Bar)
Invalid typename 'Baggy::Foo::TypeB'
at /tmp/invalid-typename-bug/lib/Bar.pm (Bar):7

If type=class, the error is:

===SORRY!=== Error while compiling /tmp/invalid-typename-bug/lib/Bar.pm (Bar)
'Bar' cannot inherit from 'Baggy::Foo::TypeB' because it is unknown.
at /tmp/invalid-typename-bug/lib/Bar.pm (Bar):7

Tested with:

$ perl6 --version
This is Rakudo version 2017.10 built on MoarVM version 2017.10
implementing Perl 6.c.
$ px --version
This is Rakudo version 2017.11-78-g1dbf5f589 built on MoarVM version 2017.11-27-gfac29990
implementing Perl 6.c.
#! /bin/sh
# Search for XXX to see what the bug requires
set -e
dir=invalid-typename-bug
mkdir $dir
cd $dir
# XXX Any of these names will cause the problem:
namespace=Pod
#namespace=Grammar
#namespace=Int
#namespace=Baggy
#namespace=IO
#namespace=DateTime
# XXX These names don't cause the problem:
#namespace=Xod
#namespace=JSON
#namespace=Zef
#namespace=Nativecall
#namespace=Test
#namespace=File
#namespace=Encode
type=role how=does
type=class how=is
mkdir -p lib/${namespace}/Foo
cat <<EOF > lib/${namespace}/Foo.pm
unit $type ${namespace}::Foo;
EOF
# XXX If this type is up a level (Pod::TypeA), it disappears
cat <<EOF > lib/${namespace}/Foo/TypeA.pm
unit $type ${namespace}::Foo::TypeA;
EOF
cat <<EOF > lib/${namespace}/Foo/TypeB.pm
use ${namespace}::Foo::TypeA;
unit $type ${namespace}::Foo::TypeB $how ${namespace}::Foo::TypeA;
EOF
cat <<EOF > lib/Bar.pm
# XXX Remove this (unused) parent namespace $type, it disappears
# XXX If this type is not named ${namespace}::Foo, it disappears
use ${namespace}::Foo;
# XXX Change these to TypeA instead of TypeB, it disappears
use ${namespace}::Foo::TypeB;
unit $type Bar $how ${namespace}::Foo::TypeB;
EOF
cat <<EOF > t.pl
use Bar;
say "Problem disappeared";
EOF
echo "Now run: PERL6LIB=$dir/lib perl6 $dir/t.pl"
cat <<'EOF'
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment