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

[BUG] EVAL throws errors in macro factories #110

Open
Nico314159 opened this issue Jul 26, 2024 · 1 comment
Open

[BUG] EVAL throws errors in macro factories #110

Nico314159 opened this issue Jul 26, 2024 · 1 comment
Assignees
Labels
Type: Bug Something isn't working

Comments

@Nico314159
Copy link
Contributor

Nico314159 commented Jul 26, 2024

Describe the bug [A clear and concise description of what the bug is.]

When using #define, defining another macro factory in terms of EVAL expressions results in a parsing error.

To Reproduce [Steps to reproduce the behavior]

  1. Write the following code in a .hjmc file:
#define SCALE 480
#bind EVAL
#define Units(x) EVAL((x * SCALE) \ 1)
  1. Use jmc compile
  2. Read the error message that appears in console.

Expected behavior [A clear and concise description of what you expected to happen.]

I expect that the code would compile without error, and that if something like Units(1.5) appeared in the main code, it would be automatically replaced with 720

Actual behavior

I get the following error.

EvaluationException
Unable to evaluate expression '(x * 480)\1'`

Desktop

  • Can replicate on both my 2020 M1 MacBook Air and my 2022 M2 MacBook Air, running MacOS Sonoma
@Nico314159 Nico314159 added the Type: Bug Something isn't working label Jul 26, 2024
@WingedSeal
Copy link
Owner

This is a problem in __parse_header which it tries to parse line #define Units(x) EVAL((x * SCALE) \ 1) then tries to evaluate EVAL((x * SCALE) \ 1) first which obviously fails. Parsing header depends on the tokenizer which completely parse out the replacement tokens for define first. A possible solution is to hoist binding EVAL to the last stage of parsing header somehow, then apply it back again somehow. I'll look into this later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants