elm-lang / elm-repl

A REPL for Elm
BSD 3-Clause "New" or "Revised" License
170 stars 34 forks source link

Race conditions when pasting many lines at once #76

Open grzegorzbalcerek opened 9 years ago

grzegorzbalcerek commented 9 years ago

There seem to be some kind of race condition in elm repl. Here are the symptoms. I am opening a repl session (Windows) and then pasting a list of commands in one go. Sometimes the result of a given command is not shown, and instead the previous result is repeated. Here are examples:

$ elm repl
Elm REPL 0.4.2 (Elm Platform 0.15.1)
  See usage examples at <https://github.com/elm-lang/elm-repl>
  Type :help for help, :exit to exit
> import List exposing (..)
> map
<function> : (a -> b) -> List a -> List b
> map2
<function: map2> : (a -> b -> c) -> List a -> List b -> List c
> map3
<function: map3> : (a -> b -> c -> d) -> List a -> List b -> List c -> List d
> map4
<function: map3> : (a -> b -> c -> d) -> List a -> List b -> List c -> List d
> :exit

$ elm repl
Elm REPL 0.4.2 (Elm Platform 0.15.1)
  See usage examples at <https://github.com/elm-lang/elm-repl>
  Type :help for help, :exit to exit
> import List exposing (..)
> map
<function> : (a -> b) -> List a -> List b
> map2
<function: map2> : (a -> b -> c) -> List a -> List b -> List c
> map3
<function: map2> : (a -> b -> c) -> List a -> List b -> List c
> map4
<function: map4>
    : (a -> b -> c -> d -> e)
      -> List a -> List b -> List c -> List d -> List e
> map5
<function: map5>
    : (a -> b -> c -> d -> e -> f)
      -> List a -> List b -> List c -> List d -> List e -> List f
> map
<function> : (a -> b) -> List a -> List b
> map2
<function: map2> : (a -> b -> c) -> List a -> List b -> List c
> map3
<function: map3> : (a -> b -> c -> d) -> List a -> List b -> List c -> List d
> map4
<function: map3> : (a -> b -> c -> d) -> List a -> List b -> List c -> List d
> map5
<function: map5>
    : (a -> b -> c -> d -> e -> f)
      -> List a -> List b -> List c -> List d -> List e -> List f
>

To try to reproduce, open elm repl and then paste the whole list of commands to it:

import List exposing (..)
map
map2
map3
map4
map5

The problem does not seem to happen when the commands are entered one by one, when the next one is entered after the previous one showed the result already.

jacobat commented 8 years ago

Problem still present in 0.17:

---- elm repl 0.17.0 -----------------------------------------------------------
 :help for help, :exit to exit, more at <https://github.com/elm-lang/elm-repl>
--------------------------------------------------------------------------------
> f x = x
<function> : a -> a
> f 3
3 : number
> f 4
4 : number
> f 5
5 : number
> f 4
5 : number
jacobat commented 8 years ago

Also, this is not limited to when pasting - the example I gave was from direct input into the repl.