Skip to content

Commit

Permalink
Stop REPL complaining about "useless use"
Browse files Browse the repository at this point in the history
As discovered by Horst H. von Brand in #4057, was introduced with
7c0a81f501d8956c5

The solution is to wrap each command given in a ( ).sink, to stop
the useless use warning.
  • Loading branch information
lizmat committed Nov 23, 2020
1 parent a68b8ab commit eae309a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core.c/REPL.pm6
Expand Up @@ -377,7 +377,13 @@ do {
# falling through after all.
elsif $initial_out_position == $*OUT.tell {
if self.repl-print($output) {
$code ~= ";"; # make sure statement is finished

# Split on statements, but get rid of any trailing
# semi-colons first.
my @stmts = $code.subst(/ [';' \s*]* $/).split(";");
# provide sink context next time for the most recent
@stmts.push: "(@stmts.pop()).sink;";
$code = @stmts.join(";");
next;
}
}
Expand Down

3 comments on commit eae309a

@vendethiel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a few weird side-effects:

$ rlwrap raku
[...]
> ";"
;
> ;;
===SORRY!=== Error while compiling:
Unexpected closing bracket
at line 2
------> <BOL>⏏).sink;;;

@lizmat
Copy link
Contributor Author

@lizmat lizmat commented on eae309a Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, mulling that :-(

@lizmat
Copy link
Contributor Author

@lizmat lizmat commented on eae309a Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to stop the warning from happening by checking for it in the CONTROL block. Turns out the CONTROL block in REPL.pm6 never gets called: warnings appear to be handled in NQP :-(

Please sign in to comment.