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

#define FOO int* #462

Open
phadej opened this issue Mar 2, 2025 · 2 comments
Open

#define FOO int* #462

phadej opened this issue Mar 2, 2025 · 2 comments

Comments

@phadej
Copy link
Collaborator

phadej commented Mar 2, 2025

#define FOO int*

After #451, we get:

cabal run hs-bindgen -- preprocess -I. -i foo.h
PANIC!: the impossible happened
Please report this as a bug at https://github.com/well-typed/hs-bindgen/issues/
fromMacroType: 'PrimTyTyCon'
CallStack (from HasCallStack):
  panicPure, called at src/HsBindgen/C/Tc/Macro.hs:1165:26 in hs-bindgen-0.1.0-inplace:HsBindgen.C.Tc.Macro

This looks more like a TODO, not sure what's is missing though.

@sheaf
Copy link
Collaborator

sheaf commented Mar 5, 2025

The problem here is that int* gets reparsed as multiplication of the type int with the empty term, which is ill-kinded and then the macro typechecker code falls over. I will fix.

@sheaf sheaf assigned sheaf and unassigned sheaf Mar 5, 2025
@sheaf
Copy link
Collaborator

sheaf commented Mar 5, 2025

In #470 I'm changing the parser slightly so that it fails to parse instead of parsing as "int times empty". We don't want to accept something like:

#define X 3+

However, we do want to accept the example in this ticket. I think the correct way forward is to have two separate macro parsers: one for expressions, and one for types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants