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(X) (int) X is handled wrong. #441

Open
phadej opened this issue Feb 23, 2025 · 2 comments
Open

#define FOO(X) (int) X is handled wrong. #441

phadej opened this issue Feb 23, 2025 · 2 comments

Comments

@phadej
Copy link
Collaborator

phadej commented Feb 23, 2025

I see

            +DeclMacro
              MacroDecl {
                macroDeclMacro = Macro {
                  macroLoc = MultiLoc {
                    multiLocExpansion =
                    "macro_functions.h:16:9",
                    multiLocPresumed = Nothing,
                    multiLocSpelling = Nothing,
                    multiLocFile = Nothing},
                  macroName = CName "FOO",
                  macroArgs = [CName "X"],
                  macroBody = MTerm
                    (MType
                      (TypePrim
                        (PrimIntegral
                          PrimInt
                          Signed)))},
                macroDeclMacroTy =
                "(forall a. (a -> PrimTy))",

in test output. The body is incorrect, I assume parser goes wrong.

@phadej
Copy link
Collaborator Author

phadej commented Feb 23, 2025

Note that

#define FOO(X) ((int) X)

with extra parentheses does

            +DeclMacro
              MacroTcError {
                macroTcErrorMacro = Macro {
                  macroLoc = MultiLoc {
                    multiLocExpansion =
                    "macro_functions.h:16:9",
                    multiLocPresumed = Nothing,
                    multiLocSpelling = Nothing,
                    multiLocFile = Nothing},
                  macroName = CName "FOO",
                  macroArgs = [],
                  macroBody = MTerm
                    (MVar (CName "X") [])},
                macroTcError = T.concat
                  [
                    "Failed to typecheck macro:\n",
                    "Unbound variable: 'X'\n"]}])

which is different, but also wrong.

@sheaf sheaf self-assigned this Feb 28, 2025
@edsko
Copy link
Collaborator

edsko commented Mar 11, 2025

I think we should just fail to parse both of these examples; they don't need to be supported.

@edsko edsko added this to the 1: `Storable` instances milestone Mar 11, 2025
@sheaf sheaf removed their assignment Mar 11, 2025
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

3 participants