Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make banning of length() and bytes() compile time
Now uses the suggested subroutine mechanism for getting the message across
rather than actually creating multi subs for length() and bytes()
  • Loading branch information
lizmat committed Mar 7, 2014
1 parent 24c94e0 commit 318a41a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
8 changes: 8 additions & 0 deletions src/Perl6/World.nqp
Expand Up @@ -2379,6 +2379,14 @@ class Perl6::World is HLL::World {
self.walk_symbols(&evaluate);

levenshtein_candidate_heuristic(@candidates, @suggestions);
if $name eq '&length' {
@suggestions.push: 'chars';
@suggestions.push: 'graphs';
@suggestions.push: 'codes';
}
elsif $name eq '&bytes' {
@suggestions.push: '.encode($encoding).bytes';
}
return @suggestions;
}

Expand Down
15 changes: 0 additions & 15 deletions src/core/Any.pm
Expand Up @@ -400,21 +400,6 @@ proto sub item(|) is pure { * }
multi sub item(*@a) { my $ = @a }
multi sub item(Mu $a) { $a }

proto sub length(|) { * }
multi sub length (|) is hidden_from_backtrace {
fail X::Routine::Banned.new(
banned => "length()",
didyoumean => "chars(), graphs() or codes()",
)
}
proto sub bytes(|) { * }
multi sub bytes (|) is hidden_from_backtrace {
fail X::Routine::Banned.new(
banned => "bytes()",
didyoumean => ".encode(\$encoding).bytes",
)
}

my $default= []; # so that we can check missing parameters
sub RWPAIR(\k, \v) { # internal fast pair creation
my \p := nqp::create(Pair);
Expand Down

0 comments on commit 318a41a

Please sign in to comment.