A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/andyarvanitis/purescript-native/issues/53 below:

ObjectUpdate seems to need deep copy · Issue #53 · andyarvanitis/purescript-native · GitHub

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 }

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4