ConstPtr lost in stub generation
I am transitioning the tree-sitter bindings from ccall
to capi
and I observe that with the following header:
const char* ts_language_symbol_name(const TSLanguage*, TSSymbol);
and foreign import declaration:
foreign import capi unsafe "tree_sitter/api.h ts_language_symbol_name"
ts_language_symbol_name :: ConstPtr Language -> TSSymbol -> IO CString
I get the following warning message
/tmp/ghc2287359_0/ghc_6.c:12:139: error:
warning: returning 'const char *' from a function with result type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
12 | char* ghczuwrapperZC2ZCtreezmsitterzm0zi9zi0zi3zminplaceZCTreeSitterziLanguageZCtszulanguagezusymbolzuname
(void* a1, HsWord16 a2) {return ts_language_symbol_name(a1, a2);}
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The void* a1
is particularly worrying. I can't explain it.
Repro
-
git clone --recursive https://github.com/Kleidukos/haskell-tree-sitter
and checkout commit https://github.com/Kleidukos/haskell-tree-sitter/commit/c156f5d26ee728930407d324cf538bc74ccbe58b - Run
cabal build tree-sitter
- Observe.