File tree 2 files changed +34
-0
lines changed 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -4057,6 +4057,31 @@ sub pp_leavetry {
4057
4057
return " eval {\n\t " . $self -> pp_leave(@_ ) . " \n\b }" ;
4058
4058
}
4059
4059
4060
+ sub pp_leavetrycatch {
4061
+ my $self = shift ;
4062
+ my ($op ) = @_ ;
4063
+
4064
+ # Expect that the first three kids should be (entertrycatch, poptry, catch)
4065
+ my $entertrycatch = $op -> first;
4066
+ $entertrycatch -> name eq " entertrycatch" or die " Expected entertrycatch as first child of leavetrycatch" ;
4067
+
4068
+ my $tryblock = $entertrycatch -> sibling;
4069
+ $tryblock -> name eq " poptry" or die " Expected poptry as second child of leavetrycatch" ;
4070
+
4071
+ my $catch = $tryblock -> sibling;
4072
+ $catch -> name eq " catch" or die " Expected catch as third child of leavetrycatch" ;
4073
+
4074
+ my $catchblock = $catch -> first-> sibling;
4075
+ $catchblock -> name eq " scope" or die " Expected scope as second child of catch" ;
4076
+
4077
+ my $trycode = scopeop(0, $self , $tryblock );
4078
+ my $catchvar = $self -> padname($catch -> targ);
4079
+ my $catchcode = scopeop(0, $self , $catchblock );
4080
+
4081
+ return " try {\n\t $trycode \n\b }\n " .
4082
+ " catch($catchvar ) {\n\t $catchcode \n\b }\cK " ;
4083
+ }
4084
+
4060
4085
sub _op_is_or_was {
4061
4086
my ($op , $expect_type ) = @_ ;
4062
4087
my $type = $op -> type;
Original file line number Diff line number Diff line change @@ -3162,3 +3162,12 @@ $a = int($c == $d != $e);
3162
3162
$a = $b < ($c == $d != $e);
3163
3163
$a = $b == ($c == $d != $e);
3164
3164
$a = $b & $c == $d != $e;
3165
+ ####
3166
+ # try/catch
3167
+ # CONTEXT use feature 'try'; no warnings 'experimental::try';
3168
+ try {
3169
+ FIRST();
3170
+ }
3171
+ catch($var) {
3172
+ SECOND();
3173
+ }
You can’t perform that action at this time.
0 commit comments