Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
change X::Comp to mean "potentially compile-time"
There are some cases (like trait application and quasi unsplicing)
that usually happen at compile time, but not always.
When they were thrown at run time, they warned, because
file name and line number were Any. This is now fixed.
  • Loading branch information
moritz committed Aug 30, 2012
1 parent 7d10d1a commit cd02586
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Perl6/World.pm
Expand Up @@ -1916,6 +1916,7 @@ class Perl6::World is HLL::World {
if $type_found {
%opts<line> := HLL::Compiler.lineof($/.orig, $/.from);
%opts<modules> := p6ize_recursive(@*MODULES);
%opts<is-compile-time> := 1;
for %opts -> $p {
if pir::does($p.value, 'array') {
my @a := [];
Expand Down
27 changes: 19 additions & 8 deletions src/core/Exception.pm
Expand Up @@ -55,6 +55,8 @@ my class Exception {
$return($fail) unless nqp::isnull($return);
$fail
}

method is-compile-time { False }
}

my class X::AdHoc is Exception {
Expand Down Expand Up @@ -154,7 +156,7 @@ do {
my $e := EXCEPTION($ex);
my Mu $err := pir::getstderr__P();

if X::Comp.ACCEPTS($e) || is_runtime($ex.backtrace) {
if $e.is-compile-time || is_runtime($ex.backtrace) {
$err.print: $e.gist;
$err.print: "\n";
}
Expand Down Expand Up @@ -304,23 +306,32 @@ my role X::Comp is Exception {
has $.line;
has $.column;
has @.modules;
has $.is-compile-time = False;
multi method gist(::?CLASS:D:) {
my $r = "===SORRY!===\n$.message\nat $.filename():$.line";
for @.modules.reverse[1..*] {
$r ~= $_<module>.defined
?? "\n from module $_<module> ($_<filename>:$_<line>)"
!! "\n from $_<filename>:$_<line>";
if $.is-compile-time {
my $r = "===SORRY!===\n$.message\nat $.filename():$.line";
for @.modules.reverse[1..*] {
$r ~= $_<module>.defined
?? "\n from module $_<module> ($_<filename>:$_<line>)"
!! "\n from $_<filename>:$_<line>";
}
$r;
}
else {
self.Exception::gist;
}
$r;
}
method SET_FILE_LINE($file, $line) {
$!filename = $file;
$!line = $line;
$!is-compile-time = True;
}
}

# XXX a hack for getting line numbers from exceptions from the metamodel
my class X::Comp::AdHoc is X::AdHoc does X::Comp { }
my class X::Comp::AdHoc is X::AdHoc does X::Comp {
method is-compile-time() { True }
}

my role X::Syntax does X::Comp { }
my role X::Pod { }
Expand Down

0 comments on commit cd02586

Please sign in to comment.