elm-repl icon indicating copy to clipboard operation
elm-repl copied to clipboard

Race conditions when pasting many lines at once

Open grzegorzbalcerek opened this issue 9 years ago • 2 comments

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.

grzegorzbalcerek avatar Aug 21 '15 00:08 grzegorzbalcerek

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 avatar May 19 '16 20:05 jacobat

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

jacobat avatar May 19 '16 20:05 jacobat