Closed
Description
It seems that object values are overwritten by shallow copy.
https://github.com/andyarvanitis/purescript-native/blob/golang/src/CodeGen/IL.hs#L183
I don't have a pr, but for now I just report.
I noticed that during my recent work.
https://github.com/opyapeus/psimp
Example
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
-- ObjectUpdate
passYear :: forall a. { age :: Int | a } -> { age :: Int | a }
passYear x = x { age = x.age + 1 }
main :: Effect Unit
main = do
let
r = { age: 1 }
log $ show r
log $ show $ passYear r
log $ show r
gets:
{ age: 1 }
{ age: 2 }
{ age: 2 }
expected:
{ age: 1 }
{ age: 2 }
{ age: 1 }