@@ -3,6 +3,11 @@ fun update(xs: list<int>): console list<int>
33 println(if xs. unsafe-is-unique then "unique a " else "not unique a " )
44 xs. map fn (x)
55 x + 1
6+
7+ fun update-trace (xs : list < int > ): list < int >
8+ trace(if xs. unsafe-is-unique then "unique a " else "not unique a " )
9+ xs. map fn (x)
10+ x + 1
611
712// This is unsafe, since the behavior that depends on this check needs to be observationally equivalent
813inline fip extern unsafe-is-unique ( ^ v : list < a> ) : bool
@@ -51,13 +56,13 @@ fun main()
5156 println("Fip update to item in local vector variable " )
5257 var a1 := vector-init-total(3 , fn (i) [i])
5358 a1[1 ] := [5 ]
54- update( std/core/types/ @byref(a1), 2 , update)
59+ std/core/types/ @byref(a1). update( 2 , update-trace )
5560 a1. map(fn (x) x. show). join("" ). println
5661
5762 println("Non-fip update to item in local vector variable " )
5863 var a2 := vector-init-total(3 , fn (i) [i])
5964 val a3 = a2
60- update( std/core/types/ @byref(a2), 2 , update)
65+ std/core/types/ @byref(a2). update( 2 , update-trace )
6166 a2. map(fn (x) x. show). join("" ). println
6267 a3. map(fn (x) x. show). join("" ). println
6368
@@ -77,48 +82,48 @@ fun update-throw2(x: list<int>)
7782// The nice thing about multiple references is that it will always be copied - so there is no issue
7883// The problem with exceptions, is the reference count is too low
7984//
80- fun test-error1 ()
81- println("Non-fip update to item in local vector variable " )
82- var a2 := vector-init-total(3 , fn (i) [i])
83- val a3 = a2
84- try {
85- update(std/core/types/ @byref(a2), 2 , update-throw)
86- a2. map(fn (x) x. show). join("" ). println
87- } fn (err) {
88- match err. info
89- ExnL (l) -> println(if l. unsafe-is-unique then "unique a " else "not unique a " )
90- a2. foreach(fn (x) x. show. trace)
91- }
85+ // fun test-error1()
86+ // println("Non-fip update to item in local vector variable")
87+ // var a2 := vector-init-total(3, fn(i) [i])
88+ // val a3 = a2
89+ // try {
90+ // update(std/core/types/@byref(a2), 2, update-throw)
91+ // a2.map(fn(x) x.show).join("").println
92+ // } fn(err) {
93+ // match err.info
94+ // ExnL(l) -> println(if l.unsafe-is-unique then "unique a" else "not unique a")
95+ // a2.foreach(fn(x) x.show.trace)
96+ // }
9297
93- fun test-error2 ()
94- println("Non-fip update to item in local vector variable " )
95- val a4 = vector-init-total(3 , fn (i) [i])
96- var a5 := a4
97- try {
98- update(std/core/types/ @byref(a5), 2 , update-throw)
99- a5. map(fn (x) x. show). join("" ). println
100- } fn (err) {
101- match err. info
102- ExnL (l) -> println(if l. unsafe-is-unique then "unique a " else "not unique a " )
103- a5. foreach(fn (x) x. show. trace)
104- }
98+ // fun test-error2()
99+ // println("Non-fip update to item in local vector variable")
100+ // val a4 = vector-init-total(3, fn(i) [i])
101+ // var a5 := a4
102+ // try {
103+ // update(std/core/types/@byref(a5), 2, update-throw)
104+ // a5.map(fn(x) x.show).join("").println
105+ // } fn(err) {
106+ // match err.info
107+ // ExnL(l) -> println(if l.unsafe-is-unique then "unique a" else "not unique a")
108+ // a5.foreach(fn(x) x.show.trace)
109+ // }
105110
106- fun test-error3 ()
107- println("Non-fip update to item in local vector variable " )
108- val a6 = vector-init-total(3 , fn (i) [i])
109- var a7 := a6
110- try {
111- update(std/core/types/ @byref(a7), 2 , update-throw)
112- a7. map(fn (x) x. show). join("" ). println
113- } fn (err) {
114- match err. info
115- ExnL (l) -> println(if l. unsafe-is-unique then "unique a " else "not unique a " )
116- a7. foreach(fn (x) x. show. trace)
117- }
111+ // fun test-error3()
112+ // println("Non-fip update to item in local vector variable")
113+ // val a6 = vector-init-total(3, fn(i) [i])
114+ // var a7 := a6
115+ // try {
116+ // update(std/core/types/@byref(a7), 2, update-throw)
117+ // a7.map(fn(x) x.show).join("").println
118+ // } fn(err) {
119+ // match err.info
120+ // ExnL(l) -> println(if l.unsafe-is-unique then "unique a" else "not unique a")
121+ // a7.foreach(fn(x) x.show.trace)
122+ // }
118123
119124// This works for some reason?
120- fun test-error4 ()
121- println("Non-fip update to item in local vector variable " )
122- val a6 = vector-init-total(3 , fn (i) [i])
123- var a7 := a6
124- update(std/core/types/ @byref(a7), 2 , update-throw)
125+ // fun test-error4()
126+ // println("Non-fip update to item in local vector variable")
127+ // val a6 = vector-init-total(3, fn(i) [i])
128+ // var a7 := a6
129+ // update(std/core/types/@byref(a7), 2, update-throw)
0 commit comments