Skip to content

Commit

Permalink
Fix "Invalid ....BUILDALL plan: 24" error
Browse files Browse the repository at this point in the history
The BUILDPLAN logic didn't cope too well with primspec 10.
  • Loading branch information
niner committed Feb 1, 2022
1 parent ffa09ff commit 118a0c3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Perl6/Metamodel/BUILDPLAN.nqp
Expand Up @@ -18,7 +18,7 @@ role Perl6::Metamodel::BUILDPLAN {
# 2 class name attr_name = set a native num attribute from init hash
# 3 class name attr_name = set a native str attribute from init hash
# 4 class attr_name code = call default value closure if needed
# 5 class attr_name code = call default value closure if needed, int attr
# 5 class attr_name code = call default value closure if needed, int or uint attr
# 6 class attr_name code = call default value closure if needed, num attr
# 7 class attr_name code = call default value closure if needed, str attr
# 8 die if a required attribute is not present
Expand All @@ -31,6 +31,7 @@ role Perl6::Metamodel::BUILDPLAN {
# 15 die if a required int attribute is 0
# 16 die if a required num attribute is 0e0
# 17 die if a required str attribute is null_s (will be '' in the future)
# 24 die if a required uint attribute is 0
method create_BUILDPLAN($obj) {
# First, we'll create the build plan for just this class.
my @plan;
Expand Down Expand Up @@ -138,7 +139,7 @@ role Perl6::Metamodel::BUILDPLAN {
if nqp::can($_, 'required') && $_.required {
my $type := $_.type;
my int $primspec := nqp::objprimspec($type);
my int $op := $primspec ?? 14 + $primspec !! 8;
my int $op := $primspec ?? $primspec == 10 ?? 24 !! 14 + $primspec !! 8;
nqp::push(@plan,[$op, $obj, $_.name, $_.required]);
nqp::deletekey(%attrs_untouched, $_.name);
}
Expand All @@ -159,7 +160,7 @@ role Perl6::Metamodel::BUILDPLAN {
# compile check constants for correct type
if nqp::isconcrete($default) {
my $name := $_.name;
my $opcode := $primspec || !$_.is_bound ?? 4 + $primspec !! 14;
my $opcode := $primspec || !$_.is_bound ?? $primspec == 10 ?? 5 !! 4 + $primspec !! 14;
my @action := [$opcode, $obj, $name, $default];

# binding defaults to additional check at runtime
Expand Down
7 changes: 6 additions & 1 deletion src/Perl6/World.nqp
Expand Up @@ -3895,7 +3895,7 @@ class Perl6::World is HLL::World {
# 15 = die if int is 0
# 16 = die if num is 0e0
# 17 = die if str is null_s
elsif $code == 8 || $code >= 15 && $code <= 17 {
elsif $code == 8 || $code >= 15 && $code <= 17 || $code == 24 {
# nqp::unless(
# nqp::p6attrinited(nqp::getattr(self,Foo,'$!a')),
# X::Attribute::Required.new(name => '$!a', why => (value))
Expand All @@ -3920,6 +3920,11 @@ class Perl6::World is HLL::World {
)
);
}
elsif $code == 24 {
$check := QAST::Op.new( :op<getattr_u>,
$!self, $class, $attr
);
}
else {
$check := QAST::Op.new( :op<p6attrinited>,
QAST::Op.new( :op<getattr>,
Expand Down
2 changes: 1 addition & 1 deletion tools/templates/NQP_REVISION
@@ -1 +1 @@
2021.12-34-g7a93ff143
2021.12-37-gc743974ec

0 comments on commit 118a0c3

Please sign in to comment.