Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL multi-row input does not handle correctly catch #4393

Closed
Glavo opened this issue Apr 27, 2018 · 3 comments · Fixed by #14519
Closed

REPL multi-row input does not handle correctly catch #4393

Glavo opened this issue Apr 27, 2018 · 3 comments · Fixed by #14519

Comments

@Glavo
Copy link
Contributor

Glavo commented Apr 27, 2018

scala> try {
         ???
       } catch { 
3 |} catch {
  |        ^
  |        '}' expected, but eof found
scala> 
@allanrenucci
Copy link
Contributor

To fix this, one would need to change the parser to emit an incompleteInputError

@Blaisorblade Blaisorblade self-assigned this Jul 24, 2018
@Blaisorblade
Copy link
Contributor

I have a fix, but do we have tests for these things?

Blaisorblade added a commit to dotty-staging/dotty that referenced this issue Jul 24, 2018
Min tests: `try { ??? } catch {}` (can be scripted) and `try { ??? } catch {`.
Blaisorblade added a commit to dotty-staging/dotty that referenced this issue Jul 25, 2018
Min tests: `try { ??? } catch {}` (can be scripted) and `try { ??? } catch {`.
@allanrenucci
Copy link
Contributor

@Blaisorblade I don't think we have. It should be fairly easy to create parser unit tests though:

def myTest = {
  val source = new SourceFile("<test>", "try ... catch ...")
  val reporter = new StoreReporter(null)
  implicit val ctx = ...
  val incompleteHandle: MessageContainer => Context => Unit = ...
  reporter.withIncompleteHandler(incompleteHandle) {
    val parser = new Parser(source)
    parser.expr()
  }  
}

OlivierBlanvillain pushed a commit to dotty-staging/dotty that referenced this issue Mar 19, 2019
Min tests: `try { ??? } catch {}` (can be scripted) and `try { ??? } catch {`.
@Blaisorblade Blaisorblade removed their assignment Jul 1, 2020
ckipp01 added a commit to ckipp01/dotty that referenced this issue Feb 19, 2022
When parsing a `TRY` if there is an empty catch block instead of just
returning a syntax error return an incomplete if you're at the EOF. This
ensures that in the REPL if you are in a position like:

```scala
scala> try {
     | ???
     | } catch
```

And you hit enter you'll still be able to continue.

Fixes scala#4393
ckipp01 added a commit to ckipp01/dotty that referenced this issue Feb 19, 2022
When parsing a `TRY` if there is an empty catch block instead of just
returning a syntax error return an incomplete if you're at the EOF. This
ensures that in the REPL if you are in a position like:

```scala
scala> try {
     | ???
     | } catch
```

And you hit enter you'll still be able to continue.

Fixes scala#4393
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
When parsing a `TRY` if there is an empty catch block instead of just
returning a syntax error return an incomplete if you're at the EOF. This
ensures that in the REPL if you are in a position like:

```scala
scala> try {
     | ???
     | } catch
```

And you hit enter you'll still be able to continue.

Fixes scala#4393
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants