[ fix ] Add missing cases for BITS types in extractInt

e79e4277 ("[ fix ] Make Bits types use int switch statement in RefC")
made the RefC backend generate code calling `extractInt` with Bits
types, bit did not add the extra cases to `extractInt`. This commit adds
the missing cases.

Fixes #2452
This commit is contained in:
György Kurucz 2022-05-03 12:56:48 +02:00 committed by G. Allais
parent 7618491536
commit 7a5f63eab0
4 changed files with 22 additions and 0 deletions

View File

@ -69,6 +69,14 @@ Value *tailcall_apply_closure(Value *_clos, Value *arg) {
int extractInt(Value *v) {
switch (v->header.tag) {
case BITS8_TAG:
return (int)((Value_Bits8 *)v)->ui8;
case BITS16_TAG:
return (int)((Value_Bits16 *)v)->ui16;
case BITS32_TAG:
return (int)((Value_Bits32 *)v)->ui32;
case BITS64_TAG:
return (int)((Value_Bits64 *)v)->ui64;
case INT8_TAG:
return (int)((Value_Int8 *)v)->i8;
case INT16_TAG:

View File

@ -0,0 +1,9 @@
x : Bits8
x = 0
main : IO ()
main = do
putStrLn $
case x of
0 => "good"
_ => "bad"

View File

@ -0,0 +1 @@
good

4
tests/refc/issue2452/run Normal file
View File

@ -0,0 +1,4 @@
rm -rf build
$1 --no-banner --no-color --console-width 0 --cg refc -o bits_case BitsCase.idr > /dev/null
./build/exec/bits_case