Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Pact/Native.hs
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,18 @@ namespaceDef = setTopLevelOnly $ defGasRNative "namespace" namespace
where
namespace :: GasRNativeFun e
namespace g i as = case as of
[TLitString nsn] -> go g i nsn
[TLitString nsn] ->
ifExecutionFlagSet FlagDisablePact47
(go g i nsn)
(if T.null nsn then
goEmpty g i
else go g i nsn)
_ -> argsError i as

goEmpty g0 fa = computeGas' g0 fa (GUnreduced [])
$ success "Namespace reset to root"
$ evalRefs . rsNamespace .= Nothing

go g0 fa ns = do
let name = NamespaceName ns
info = _faInfo fa
Expand Down
26 changes: 26 additions & 0 deletions tests/pact/namespaces.repl
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,29 @@


(rollback-tx)

(begin-tx)

(env-exec-config ['DisablePact47])
(namespace 'carl)

(expect-failure
"Setting namespace back to root namespace pre-Pact 4.7 fork fails"
(namespace ""))

(expect
"Carl contract fqn not required for member access - no ns"
true
(carl-module.f))

(env-exec-config [])

(expect
"Setting namespace back to root namespace post-Pact 4.7 fork succeeds"
"Namespace reset to root"
(namespace ""))

(expect
"Carl contract fqn required for member access - with ns"
true
(carl.carl-module.f))