Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created February 7, 2018 11:25
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 zoffixznet/e92154b8107eac6bc154866f54cebb87 to your computer and use it in GitHub Desktop.
Save zoffixznet/e92154b8107eac6bc154866f54cebb87 to your computer and use it in GitHub Desktop.
diff --git a/src/Perl6/World.nqp b/src/Perl6/World.nqp
index d941b2149..e9a97c576 100644
--- a/src/Perl6/World.nqp
+++ b/src/Perl6/World.nqp
@@ -1622,7 +1622,7 @@ class Perl6::World is HLL::World {
%info<bind_constraint> := self.parameterize_type_with_args($/,
%info<bind_constraint>, [$vtype], nqp::hash());
%info<value_type> := $vtype;
- %info<default_value> := $vtype;
+ %info<default_value> := self.maybe-definite-how-base: $vtype;
}
else {
%info<container_type> := %info<container_base>;
@@ -1689,7 +1689,8 @@ class Perl6::World is HLL::World {
%info<bind_constraint> := self.parameterize_type_with_args($/,
%info<bind_constraint>, @value_type, nqp::hash());
%info<value_type> := @value_type[0];
- %info<default_value> := @value_type[0];
+ %info<default_value>
+ := self.maybe-definite-how-base: @value_type[0];
}
else {
%info<container_type> := %info<container_base>;
@@ -1730,7 +1731,8 @@ class Perl6::World is HLL::World {
if @value_type {
%info<bind_constraint> := @value_type[0];
%info<value_type> := @value_type[0];
- %info<default_value> := @value_type[0];
+ %info<default_value>
+ := self.maybe-definite-how-base: @value_type[0];
}
else {
%info<bind_constraint> := self.find_symbol(['Mu'], :setting-only);
@@ -1741,6 +1743,13 @@ class Perl6::World is HLL::World {
}
%info
}
+ method maybe-definite-how-base ($v) {
+ # returns the value itself, unless it's a DefiniteHOW, in which case,
+ # it returns its base type
+ nqp::eqaddr($v.HOW,
+ $*W.find_symbol: ['Metamodel','DefiniteHOW'], :setting-only
+ ) ?? $v.HOW.base_type: $v !! $v
+ }
# Installs one of the magical lexicals ($_, $/ and $!). Uses a cache to
# avoid massive duplication of containers and container descriptors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment