-
-
Save zoffixznet/6b22174b85d03c1e82a89ca28b53d3c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Perl6/Actions.nqp b/src/Perl6/Actions.nqp | |
index d7595d8..35596c1 100644 | |
--- a/src/Perl6/Actions.nqp | |
+++ b/src/Perl6/Actions.nqp | |
@@ -4964,30 +4964,21 @@ class Perl6::Actions is HLL::Actions does STDActions { | |
dissect_type_into_parameter($/, $<typename>.ast); | |
} | |
} | |
- elsif $<value> { | |
+ elsif $<numish> { | |
if nqp::existskey(%*PARAM_INFO, 'nominal_type') { | |
$*W.throw($/, ['X', 'Parameter', 'MultipleTypeConstraints'], | |
parameter => (%*PARAM_INFO<variable_name> // ''), | |
); | |
} | |
- my $ast := wanted($<value>.ast, 'type_constraint'); | |
- my $val; | |
- if nqp::can($ast,'has_compile_time_value') && $ast.has_compile_time_value { | |
- $val := $ast.compile_time_value; | |
- } | |
- else { # for negatives | |
- $val := ( | |
- $*INF_VALUE | |
- ?? $*W.add_numeric_constant(NQPMu, 'Num', ( | |
- $<sign> eq '-' || $<sign> eq '−' | |
- ?? nqp::neginf !! nqp::inf | |
- )) !! $*W.add_numeric_constant(NQPMu, 'Int', | |
- nqp::radix_I( | |
- 10, $<value>, 0, 1, $*W.find_symbol(['Int']) | |
- )[0] | |
- ) | |
- ).compile_time_value; | |
+ my $val := wanted( | |
+ $<numish>.ast, 'type_constraint' | |
+ ).compile_time_value; | |
+ | |
+ if $*NEGATE_VALUE { | |
+ my $neg-op := $*W.find_symbol(['&prefix:<->']); | |
+ $val := $neg-op($val); | |
} | |
+ | |
%*PARAM_INFO<nominal_type> := $val.WHAT; | |
unless %*PARAM_INFO<post_constraints> { | |
%*PARAM_INFO<post_constraints> := []; | |
diff --git a/src/Perl6/Grammar.nqp b/src/Perl6/Grammar.nqp | |
index 3645905..7b46bc8 100644 | |
--- a/src/Perl6/Grammar.nqp | |
+++ b/src/Perl6/Grammar.nqp | |
@@ -2945,9 +2945,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD { | |
token type_constraint { | |
:my $*IN_DECL := ''; | |
[ | |
- | <value> | |
- | <[-−]> $<value>=\d+ | |
- | <sign> $<value>=['Inf'|'∞'] :my $*INF_VALUE := 1; | |
+ | [ <[-−]> :my $*NEGATE_VALUE := 1; ]? <numish> | |
| <typename> | |
| where <.ws> <EXPR('i=')> | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment