Skip to content

Commit

Permalink
install enum after it has been created.
Browse files Browse the repository at this point in the history
also clone the enum value before downcasting it
  • Loading branch information
moritz committed May 12, 2012
1 parent 24a3016 commit f48c49d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Perl6/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2284,8 +2284,6 @@ class Perl6::Actions is HLL::Actions {
feature => "Variable case of enums",
);
}
$*W.install_package($/, $longname.type_name_parts('enum name', :decl(1)),
($*SCOPE || 'our'), 'enum', $*PACKAGE, $*W.cur_lexpad(), $type_obj);

# Get list of either values or pairs; fail if we can't.
my @values;
Expand Down Expand Up @@ -2376,6 +2374,9 @@ class Perl6::Actions is HLL::Actions {
# create a type object even for empty enums
make_type_obj unless $has_base_type;

$*W.install_package($/, $longname.type_name_parts('enum name', :decl(1)),
($*SCOPE || 'our'), 'enum', $*PACKAGE, $*W.cur_lexpad(), $type_obj);

# We evaluate to the enum type object.
make $*W.get_ref($type_obj);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Perl6/World.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,7 @@ class Perl6::World is HLL::World {
# Adds a value to an enumeration.
method create_enum_value($enum_type_obj, $key, $value) {
# Create directly.
my $val := pir::repr_change_type__0PP($value, $enum_type_obj);
my $val := pir::repr_change_type__0PP(pir::repr_clone__PP($value), $enum_type_obj);
nqp::bindattr($val, $enum_type_obj, '$!key', $key);
self.add_object($val);

Expand Down

0 comments on commit f48c49d

Please sign in to comment.