Skip to content

Commit

Permalink
file name and line need to be Perl 6 values
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Dec 1, 2011
1 parent f961892 commit dbee3a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
21 changes: 14 additions & 7 deletions src/Perl6/Actions.pm
Expand Up @@ -54,16 +54,23 @@ class Perl6::Actions is HLL::Actions {
}

method throw($/, $ex_type, *%opts) {
my $file := pir::find_caller_lex__ps('$?FILES');
%opts<line> := HLL::Compiler.lineof($/.orig, $/.from);
%opts<filename> := pir::isnull($file)
?? '<unknown file>'
!! $file;
# TODO: provide context
my $type_found := 1;
my $ex := try { $*ST.find_symbol($ex_type); CATCH { $type_found := 0 } };
my $ex := try {
CATCH { $type_found := 0 };
$*ST.find_symbol($ex_type);
};
if $type_found {
$ex.new(|%opts).throw;
my $file := pir::find_caller_lex__ps('$?FILES');
%opts<line> := nqp::box_i(
HLL::Compiler.lineof($/.orig, $/.from),
$*ST.find_symbol(['Int'])
);
%opts<filename> := nqp::box_s(
pir::isnull($file) ?? '<unknown file>' !! $file,
$*ST.find_symbol(['Str'])
);
} else {
my @err := ['Error while compiling, type ', nqp::join('::', $ex_type), "\n"];
for %opts -> $key {
Expand Down Expand Up @@ -1425,7 +1432,7 @@ class Perl6::Actions is HLL::Actions {
# Obtain parameters, create signature object and generate code to
# call binder.
if $block<placeholder_sig> && $<multisig> {
$/.CURSOR.panic('Placeholder variable cannot override existing signature');
self.throw($/, ['X', 'Signature', 'Placeholder']);
}
my @params :=
$<multisig> ?? $<multisig>[0].ast !!
Expand Down
6 changes: 0 additions & 6 deletions src/core/Exceptions.pm
Expand Up @@ -38,12 +38,6 @@ my class X::Buf::AsStr is X::Base {
}
}

my role X::Comp {
has $.filename;
has $.line;
has $.column;
}

my class X::Signature::Placeholder is X::Base does X::Comp {
method message() {
'Placeholder variable cannot override existing signature';
Expand Down

0 comments on commit dbee3a0

Please sign in to comment.