git.iko.soy/rowtype-yoga/purescm
on bytevector help sign in
Use the same symbol for `PrimUndefined` (#256)
commit21e186125c71395e567527096c27fe140e645cba authorAntti Holvikari <mail@anttih.com> dateMon 28 Oct 2024, 07:03 (2 years ago) parent1016cba
4 files changed+5−10
src/PureScript/Backend/Chez/Constants.purs−3 src/PureScript/Backend/Chez/Convert.purs+2−4 test-snapshots/src/snapshots-output/Snapshot.Literals.Record.ss+2−2 test-snapshots/src/snapshots-output/Snapshot.PrimUndefined.ss+1−1
src/PureScript/Backend/Chez/Constants.purs−3
@@ -22,6 +22,3 @@ moduleLib = "lib"
2222
2323schemeExt :: String
2424schemeExt = ".ss"
25−
26−undefinedSymbol :: String
27−undefinedSymbol = "purs-undefined"
src/PureScript/Backend/Chez/Convert.purs+2−4
@@ -22,7 +22,7 @@ import Data.String.Regex.Unsafe as R.Unsafe
2222import Data.Tuple (Tuple(..), uncurry)
2323import Data.Tuple as Tuple
2424import Partial.Unsafe (unsafeCrashWith)
25−import PureScript.Backend.Chez.Constants (libChezSchemePrefix, moduleForeign, moduleLib, rtPrefixed, runtimePrefix, scmPrefixed, undefinedSymbol)
25+import PureScript.Backend.Chez.Constants (libChezSchemePrefix, moduleForeign, moduleLib, rtPrefixed, runtimePrefix, scmPrefixed)
2626import PureScript.Backend.Chez.Syntax (ChezDefinition(..), ChezExport(..), ChezExpr, ChezImport(..), ChezImportSet(..), ChezLibrary, recordTypeAccessor, recordTypeCurriedConstructor, recordTypePredicate, recordTypeUncurriedConstructor)
2727import PureScript.Backend.Chez.Syntax as S
2828import PureScript.Backend.Optimizer.Convert (BackendModule, BackendBindingGroup)
@@ -234,9 +234,7 @@ codegenExpr codegenEnv@{ currentModule } s = case unwrap s of
234234
235235 PrimOp o ->
236236 codegenPrimOp codegenEnv o
237− PrimUndefined ->
238− S.app (S.Identifier $ scmPrefixed "gensym")
239− (S.StringExpr $ Json.stringify $ Json.fromString undefinedSymbol)
237+ PrimUndefined -> S.quote $ S.Identifier "undefined"
240238
241239 Fail i ->
242240 -- Note: This can be improved by using `error`, but it requires
test-snapshots/src/snapshots-output/Snapshot.Literals.Record.ss+2−2
@@ -20,7 +20,7 @@
2020
2121 (scm:define insert
2222 (((Record.insert (scm:list (scm:cons (scm:string->symbol "reflectSymbol") (scm:lambda (_)
23− (rt:string->pstring "anotherField"))))) (scm:gensym "purs-undefined")) (scm:gensym "purs-undefined")))
23+ (rt:string->pstring "anotherField"))))) (scm:quote undefined)) (scm:quote undefined)))
2424
2525 (scm:define recordUpdate
2626 (scm:lambda (v0)
@@ -38,7 +38,7 @@
3838 (scm:let*
3939 ([r0 (scm:list (scm:cons (scm:string->symbol "fooBarBaz") 5))]
4040 [s1 (recordUpdate r0)]
41− [t2 ((recordAddField (scm:gensym "purs-undefined")) s1)]
41+ [t2 ((recordAddField (scm:quote undefined)) s1)]
4242 [u3 (scm:list (scm:cons (scm:string->symbol "fooBarBaz") minusTwo))]
4343 [_4 (Test.Assert.assert (scm:fx=? (recordAccess t2) 10))])
4444 (scm:lambda ()
test-snapshots/src/snapshots-output/Snapshot.PrimUndefined.ss+1−1
@@ -13,7 +13,7 @@
1313
1414 (scm:define testCase
1515 (scm:lambda (dictRing0)
16− (rt:record-ref ((rt:record-ref dictRing0 (scm:string->symbol "Semiring0")) (scm:gensym "purs-undefined")) (scm:string->symbol "add"))))
16+ (rt:record-ref ((rt:record-ref dictRing0 (scm:string->symbol "Semiring0")) (scm:quote undefined)) (scm:string->symbol "add"))))
1717
1818 (scm:define main
1919 (Test.Assert.assert (scm:fx=? (((testCase Data.Ring.ringInt) 1) 1) 2))))