From 2d85f8a19c69626beed2b534fa1a86f113f03244 Mon Sep 17 00:00:00 2001 From: Jonas Kramer Date: Mon, 9 Jul 2018 12:23:58 +0200 Subject: [PATCH] Include source file name in module-not-found error message. Fixes rakudo/rakudo#2022. --- src/Perl6/World.nqp | 3 ++- src/core/CompUnit/DependencySpecification.pm6 | 1 + src/core/Exception.pm6 | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Perl6/World.nqp b/src/Perl6/World.nqp index 60298e90c3e..6921d172e81 100644 --- a/src/Perl6/World.nqp +++ b/src/Perl6/World.nqp @@ -1266,7 +1266,8 @@ class Perl6::World is HLL::World { :auth-matcher(%opts // $true), :api-matcher(%opts // $true), :version-matcher(%opts // $true), - :source-line-number($line) + :source-line-number($line), + :source-file-name(self.current_file) ); self.add_object($spec); my $registry := self.find_symbol(['CompUnit', 'RepositoryRegistry'], :setting-only); diff --git a/src/core/CompUnit/DependencySpecification.pm6 b/src/core/CompUnit/DependencySpecification.pm6 index 00fa9c3b40a..2ffda670e5b 100644 --- a/src/core/CompUnit/DependencySpecification.pm6 +++ b/src/core/CompUnit/DependencySpecification.pm6 @@ -1,6 +1,7 @@ class CompUnit::DependencySpecification { has str $.short-name is required; has int $.source-line-number = 0; + has str $.source-file-name = ''; has str $.from = 'Perl6'; has $.version-matcher = True; has $.auth-matcher = True; diff --git a/src/core/Exception.pm6 b/src/core/Exception.pm6 index b775c37fcdb..7d29c81ad88 100644 --- a/src/core/Exception.pm6 +++ b/src/core/Exception.pm6 @@ -2958,9 +2958,10 @@ my class X::CompUnit::UnsatisfiedDependency is Exception { method message() { my $name = $.specification.short-name; my $line = $.specification.source-line-number; + my $file = $.specification.source-file-name; is-core($name) ?? "{$name} is a builtin type, not an external module" - !! "Could not find $.specification at line $line in:\n" + !! "Could not find $.specification at $file:$line in:\n" ~ $*REPO.repo-chain.map(*.Str).join("\n").indent(4) ~ ($.specification ~~ / $=.+ '::from' $ / ?? "\n\nIf you meant to use the :from adverb, use"