Skip to content

Commit

Permalink
FIX: make sure, that values from _safe_ scheme are always copied, if …
Browse files Browse the repository at this point in the history
…possible
  • Loading branch information
Oldes committed Jul 12, 2022
1 parent b6108ec commit ec99595
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/mezz/base-defs.reb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ immediate!: make typeset! [
; Does not include internal datatypes
none! logic! scalar! date! any-word! datatype! typeset! event!
]
copyable!: make typeset! [
series! port! map! object! bitset! any-function! error!
]

system/options/result-types: make typeset! [
immediate! series! bitset! image! object! map! gob! handle! struct! ;module!
Expand Down
8 changes: 7 additions & 1 deletion src/mezz/codec-safe.reb
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,13 @@ sys/make-scheme [
]
file: port/spec/ref
date: none
get: func[key][select data :key]
get: func[key /local value][
; returned values are always copied, if possible, so
; they are not modified by accident from outside
either find copyable! type? value: select data :key [
copy/deep :value
][ :value ]
]
set: func[key [word!] val [any-type!]][put data :key :val]
rem: func[key][remove/key data :key #[unset!]]
load: does [
Expand Down

0 comments on commit ec99595

Please sign in to comment.