Skip to content

Commit

Permalink
[js] Also type check when resetting a Scalar to a default with Nil
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Oct 27, 2017
1 parent 44ef8fc commit 994940a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/vm/js/perl6-runtime/runtime.js
Expand Up @@ -393,16 +393,17 @@ module.exports.load = function(nqp, CodeRef, Capture, containerSpecs) {
value = desc.$$getattr(ContainerDescriptor, '$!default');
} else {
value = maybeValue;
let of = desc.$$getattr(ContainerDescriptor, '$!of');
if (of !== Mu && value.$$istype(ctx, of)=== 0) {
let name = desc.$$getattr_s(ContainerDescriptor, '$!name');
let thrower = getThrower("X::TypeCheck::Assignment");
}

let of = desc.$$getattr(ContainerDescriptor, '$!of');
if (of !== Mu && value.$$istype(ctx, of)=== 0) {
let name = desc.$$getattr_s(ContainerDescriptor, '$!name');
let thrower = getThrower("X::TypeCheck::Assignment");

if (thrower === null) {
ctx.die("Type check failed in assignment to '" + name + "'");
} else {
thrower.$$call(ctx, null, name, value, of);
}
if (thrower === null) {
ctx.die("Type check failed in assignment to '" + name + "'");
} else {
thrower.$$call(ctx, null, name, value, of);
}
}

Expand Down

0 comments on commit 994940a

Please sign in to comment.