Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
allow negative integers as parameters
  • Loading branch information
TimToady committed Sep 19, 2015
1 parent 6252fc4 commit ea2d21c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Perl6/Actions.nqp
Expand Up @@ -4367,10 +4367,14 @@ Compilation unit '$file' contained the following violations:
);
}
my $ast := $<value>.ast;
unless $ast.has_compile_time_value {
$/.CURSOR.panic('Cannot use a value type constraints whose value is unknown at compile time');
my $val;
if nqp::can($ast,'has_compile_time_value') && $ast.has_compile_time_value {
$val := $ast.compile_time_value;
}
else { # for negatives
my $i := $*W.add_numeric_constant(NQPMu, 'Int', +$<value>.Str);
$val := $i.compile_time_value;
}
my $val := $ast.compile_time_value;
%*PARAM_INFO<nominal_type> := $val.WHAT;
unless %*PARAM_INFO<post_constraints> {
%*PARAM_INFO<post_constraints> := [];
Expand Down
1 change: 1 addition & 0 deletions src/Perl6/Grammar.nqp
Expand Up @@ -2839,6 +2839,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD {
:my $*IN_DECL := '';
[
| <value>
| $<value>=['-'\d+]
| <typename>
| where <.ws> <EXPR('i=')>
]
Expand Down

0 comments on commit ea2d21c

Please sign in to comment.