Skip to content

Commit 3e91a9c

Browse files
NadiaYvetteandreasabel
authored andcommitted
annotate comparison subexpressions in AlexTemplate
GTE() and EQ() were getting the following errors for the monadUserState-strict-text and possibly other cases with -XImpredicativeTypes enabled: basic_typeclass.i.hs:877:28: error: [GHC-36495] • tagToEnum# must appear applied to one value argument • In the first argument of ‘(&&)’, namely ‘(GHC.Exts.tagToEnum# (offset >=# 0#))’ In the expression: (GHC.Exts.tagToEnum# (offset >=# 0#)) && let check = alexIndexInt16OffAddr alex_check offset in (GHC.Exts.tagToEnum# (check ==# ord_c)) In the expression: if (GHC.Exts.tagToEnum# (offset >=# 0#)) && let check = alexIndexInt16OffAddr alex_check offset in (GHC.Exts.tagToEnum# (check ==# ord_c)) then alexIndexInt16OffAddr alex_table offset else alexIndexInt16OffAddr alex_deflt s | 877 | new_s = if GTE(offset,ILIT(0)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Annotating the tagToEnum# usage to specify which Enum is intended was one case. Another was annotating the results of ==# and >=# to resolve some ambiguity involved there.
1 parent d51506c commit 3e91a9c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

data/AlexTemplate.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@
1313
# define FAST_INT Int#
1414
-- Do not remove this comment. Required to fix CPP parsing when using GCC and a clang-compiled alex.
1515
# if __GLASGOW_HASKELL__ > 706
16-
# define GTE(n,m) (GHC.Exts.tagToEnum# (n >=# m))
17-
# define EQ(n,m) (GHC.Exts.tagToEnum# (n ==# m))
16+
# define CMP_GEQ(n,m) (((n) >=# (m)) :: Int#)
17+
# define CMP_EQ(n,m) (((n) ==# (m)) :: Int#)
18+
# define CMP_MKBOOL(x) ((GHC.Exts.tagToEnum# (x)) :: Bool)
1819
# else
19-
# define GTE(n,m) (n >=# m)
20-
# define EQ(n,m) (n ==# m)
20+
# define CMP_GEQ(n,m) (((n) >= (m)) :: Bool)
21+
# define CMP_EQ(n,m) (((n) == (m)) :: Bool)
22+
# define CMP_MKBOOL(x) ((x) :: Bool)
2123
# endif
24+
# define GTE(n,m) CMP_MKBOOL(CMP_GEQ(n,m))
25+
# define EQ(n,m) CMP_MKBOOL(CMP_EQ(n,m))
2226
# define PLUS(n,m) (n +# m)
2327
# define MINUS(n,m) (n -# m)
2428
# define TIMES(n,m) (n *# m)

0 commit comments

Comments
 (0)