Skip to content

Commit

Permalink
[js] Die when we get out of order parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Aug 14, 2018
1 parent dde8f1f commit 3ef0f88
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/vm/js/Compiler.nqp
Expand Up @@ -505,6 +505,9 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
}

if $param.default {
if $pos_slurpy {
nqp::die("Optional positionals must come before all slurpy positionals");
}
$pos_optional := $pos_optional + 1;
my $default_value := self.as_js($param.default, :want($type));
@setup.push(Chunk.void(
Expand All @@ -514,6 +517,12 @@ class QAST::CompilerJS does DWIMYNameMangling does SerializeOnce {
));
}
else {
if $pos_optional {
nqp::die("Required positionals must come before all optional positionals");
}
if $pos_slurpy {
nqp::die("Required positionals must come before all slurpy positionals");
}
$pos_required := $pos_required + 1;
@setup.push($set ~ unpack($tmp) ~ ";\n");
}
Expand Down

0 comments on commit 3ef0f88

Please sign in to comment.