Skip to content

Commit

Permalink
Make error on "my $x is Int" more awesomeo
Browse files Browse the repository at this point in the history
  $ 6 'my $x is Int'
  ===SORRY!=== Error while compiling -e
  is trait on $-sigil variable not yet implemented. Sorry.
  Did you mean: my Int $x?

- as recently discussed on perl6-language
- added optional "did-you-mean" parameter to X::NYI
- used that in $*W.container_type_info
  • Loading branch information
lizmat authored and zoffixznet committed May 26, 2017
1 parent 99feb7d commit c4b56f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/Perl6/World.nqp
Expand Up @@ -1682,7 +1682,10 @@ class Perl6::World is HLL::World {
}
else {
if @cont_type {
self.throw($/, 'X::NYI', :feature('is trait on $-sigil variable'));
self.throw($/, 'X::NYI',
:feature('is trait on $-sigil variable'),
:did-you-mean("my {@cont_type[0].HOW.name(@cont_type[0])} $sigil{~$<variable><desigilname>}")
);
}
%info<container_base> := self.find_symbol(['Scalar']);
%info<container_type> := %info<container_base>;
Expand Down
7 changes: 6 additions & 1 deletion src/core/Exception.pm
Expand Up @@ -748,7 +748,12 @@ my role X::Pod { }

my class X::NYI is Exception {
has $.feature;
method message() { "$.feature not yet implemented. Sorry. " }
has $.did-you-mean;
method message() {
my $msg = "$.feature not yet implemented. Sorry.";
$msg ~= "\nDid you mean: {$.did-you-mean.gist}?" if $.did-you-mean;
$msg
}
}
my class X::Comp::NYI is X::NYI does X::Comp { };
my class X::NYI::Available is X::NYI {
Expand Down

0 comments on commit c4b56f7

Please sign in to comment.