Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix old bool wrapper on setEcho builtin #5526

Merged
merged 2 commits into from
Jan 8, 2025
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
5 changes: 2 additions & 3 deletions unison-runtime/src/Unison/Runtime/Builtin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,11 +1015,10 @@ set'echo :: ForeignOp
set'echo instr =
([BX, BX],)
. TAbss [arg1, arg2]
. unenum 2 arg2 Ty.booleanRef bol
. TLetD result UN (TFOp instr [arg1, bol])
. TLetD result UN (TFOp instr [arg1, arg2])
$ outIoFailUnit stack1 stack2 stack3 unit fail result
where
(arg1, arg2, bol, stack1, stack2, stack3, unit, fail, result) = fresh
(arg1, arg2, stack1, stack2, stack3, unit, fail, result) = fresh

-- a -> IOMode -> ...
inIomr :: forall v. (Var v) => v -> v -> v -> v -> ANormal v -> ForeignFunc -> ([Mem], ANormal v)
Expand Down
2 changes: 1 addition & 1 deletion unison-runtime/src/Unison/Runtime/Stack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ peekOffBool stk i = do
b <- bpeekOff stk i
pure $ case b of
Enum _ t -> t /= TT.falseTag
_ -> error "peekBool: not a boolean"
_ -> error "peekOffBool: not a boolean"
{-# INLINE peekOffBool #-}

peekOffS :: Stack -> Int -> IO USeq
Expand Down
28 changes: 24 additions & 4 deletions unison-src/transcripts/idempotent/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ testSeek _ =

runTest test

testSetEcho : '{io2.IO} [Result]
testSetEcho = do
a = setEcho.impl (stdHandle StdErr) true
b = setEcho.impl (stdHandle StdErr) false
match (a, b) with
(Right _, Right _) -> [ Ok "setEcho works" ]
_ -> [ Fail "setEcho failure" ]

testAppend : '{io2.IO} [Result]
testAppend _ =
test = 'let
Expand Down Expand Up @@ -352,17 +360,19 @@ testAppend _ =

⍟ These new definitions are ok to `add`:

testAppend : '{IO} [Result]
testSeek : '{IO} [Result]
testAppend : '{IO} [Result]
testSeek : '{IO} [Result]
testSetEcho : '{IO} [Result]
```

``` ucm
scratch/main> add

⍟ I've added these definitions:

testAppend : '{IO} [Result]
testSeek : '{IO} [Result]
testAppend : '{IO} [Result]
testSeek : '{IO} [Result]
testSetEcho : '{IO} [Result]

scratch/main> io.test testSeek

Expand All @@ -380,6 +390,16 @@ scratch/main> io.test testSeek

Tip: Use view 1 to view the source of a test.

scratch/main> io.test testSetEcho

New test results:

1. testSetEcho ◉ setEcho works

✅ 1 test(s) passing

Tip: Use view 1 to view the source of a test.

scratch/main> io.test testAppend

New test results:
Expand Down
Loading