Skip to content

Commit

Permalink
RakuAST: give named placeholder params a fixed order in the signature
Browse files Browse the repository at this point in the history
The old frontend added named placeholder parameters to the signature in
the order of appearance in the block. In general we need compilation
results to be reproducible. However, we go through placeholders in hash
order. That's not a problem because positionals will be sorted
lexicographically anyway. It was a problem for nameds, so just give them
the same treatment as positionals.
  • Loading branch information
niner committed Jan 29, 2023
1 parent bab7f83 commit 445a224
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Raku/ast/code.rakumod
Expand Up @@ -537,8 +537,15 @@ class RakuAST::PlaceholderParameterOwner
}
nqp::splice(@positionals, [$placeholder], $insert-at, 0);
}
elsif nqp::istype($_, RakuAST::VarDeclaration::Placeholder::Named) {
@nameds.push($placeholder);
elsif nqp::istype($placeholder, RakuAST::VarDeclaration::Placeholder::Named) {
my int $insert-at := 0;
my str $desigil-insert := nqp::substr($placeholder.lexical-name, 1);
while $insert-at < nqp::elems(@nameds) {
my str $desigil-cur := nqp::substr(@nameds[$insert-at].lexical-name, 1);
last if $desigil-insert lt $desigil-cur;
$insert-at++;
}
nqp::splice(@nameds, [$placeholder], $insert-at, 0);
}
else {
if $placeholder.lexical-name eq '@_' { # @_ before %_
Expand Down

0 comments on commit 445a224

Please sign in to comment.