Skip to content

Commit

Permalink
Add var name to typecheck error for constants
Browse files Browse the repository at this point in the history
The initial RakuAST implementation was added in e9f438f
and this just adds the name of the variable to the message in the same
manner as the legacy implementation.
  • Loading branch information
MasterDuke17 committed May 11, 2023
1 parent 4b69dd5 commit 8bb54bf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Raku/ast/variable-declaration.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,9 @@ class RakuAST::VarDeclaration::Constant
self.get-implicit-lookups.AT-POS(0).resolution.compile-time-value;

unless nqp::istype(nqp::what($!value), $type) {
my $name := nqp::getattr_s(self, RakuAST::VarDeclaration::Constant, '$!name');
self.add-sorry($resolver.build-exception('X::Comp::TypeCheck',
operation => 'constant declaration',
operation => 'constant declaration of ' ~ ($name || '<anon>'),
expected => $type,
got => $!value
));
Expand Down

0 comments on commit 8bb54bf

Please sign in to comment.