swift: REPL broken on main

Describe the bug

On main, if you start the REPL by typing swift you don’t actually get into the REPL, you’ll just see the help and you’re back at the shell prompt (instead of the REPL prompt).

To Reproduce

Steps to reproduce the behavior:

  1. docker pull swiftlang/swift:nightly-main2.
  2. docker run -it --rm --privileged swiftlang/swift:nightly-main swift3.

Expected behavior

A REPL prompt like in Swift 5.6 (and earlier):

$ docker run -it --rm --privileged swift:5.6 swift

[...]

Welcome to Swift version 5.6.1 (swift-5.6.1-RELEASE).
Type :help for assistance.
  1>  

Screenshots

Screenshot 2022-05-12 at 4 52 38 pm

Environment (please complete the following information):

$ docker run -it --rm --privileged swiftlang/swift:nightly-main swift -version
Swift version 5.7-dev (LLVM 0111970099b6de6, Swift b6ec1874c96449c)
Target: x86_64-unknown-linux-gnu

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 27 (25 by maintainers)

Most upvoted comments

I’m surprised that piping into swift started the REPL; I would have expected it acted more like:

echo 'print("HELLO WORLD, THIS RUNS CODE.")' | cat > tmp.swift ; swift tmp.swift

I think the canonical way which also doesn’t need a file on disk is

echo 'print("hello")' | swift -

i.e. compile and execute, which has slightly different semantics from REPL mode. @weissi would that solve your issue? It seems like the new welcome screen and changes to what’s automatically printed would already cause problems for automated scripts.

I don’t personally rely on the old functionality, I was just pointing out that this is something that would break. I’m fine with changing it but I was slightly surprised by such a profound change w/o an evolution proposal.

@tomerd Though I think piping should always be supported, but only to swift repl rather than just swift