Skip to content

Commit

Permalink
Alternate fix for #4057
Browse files Browse the repository at this point in the history
Instead of trying to look for statements, take the whole of a
successful statement (whether that be from one line or multiple
lines) as a single thing, assign it to the nameless state variable
to prevent "useless use" warnings, and join that up with whatever
the next line brings when it's being evalled.
  • Loading branch information
lizmat committed Nov 26, 2020
1 parent f2ad038 commit f2851b9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core.c/REPL.pm6
Expand Up @@ -315,9 +315,11 @@ do {
}

my $prompt;
my @before;
my $code;
sub reset(--> Nil) {
$code = '';
@before = ();
$code = '';
$prompt = self.interactive_prompt;
}
reset;
Expand All @@ -342,7 +344,7 @@ do {
my $*MAIN_CTX;

my $output is default(Nil) = self.repl-eval(
$code,
@before.join ~ $code,
my $exception,
:outer_ctx($!save_ctx),
|%adverbs);
Expand Down Expand Up @@ -377,7 +379,8 @@ do {
# falling through after all.
elsif $initial_out_position == $*OUT.tell {
if self.repl-print($output) {
$code ~= ";"; # make sure statement is finished
@before.push: '$ = ' ~ $code.chomp ~ ";\n";
$code = '';
next;
}
}
Expand Down

0 comments on commit f2851b9

Please sign in to comment.