Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Unable to use control flow in macros #44

Closed
Mm2PL opened this issue Sep 24, 2021 · 3 comments
Closed

Unable to use control flow in macros #44

Mm2PL opened this issue Sep 24, 2021 · 3 comments

Comments

@Mm2PL
Copy link

Mm2PL commented Sep 24, 2021

It's impossible to use an if or while block inside of a macro, as it results in a compiler error. Simulation or compile doesn't matter, it's broken in both.

Example

macro test
    2 1 < if
        12 print
    end
end

Compile result

$ python porth.py sim borked.porth
Traceback (most recent call last):
  File "porth.py", line 924, in <module>
    program = compile_file_to_program(program_path, include_paths);
  File "porth.py", line 862, in compile_file_to_program
    return compile_tokens_to_program(lex_file(file_path), include_paths)
  File "porth.py", line 709, in compile_tokens_to_program
    block_ip = stack.pop()
IndexError: pop from empty list

Version d7ecaa2

@rexim
Copy link
Member

rexim commented Sep 24, 2021

@Mm2PL yep! It's a known issue! Thanks for reporting it, I'll fix it in the near future.

@ap29600
Copy link
Contributor

ap29600 commented Sep 24, 2021

#45 fixes this, unless @rexim wants to do it on stream.

@rexim
Copy link
Member

rexim commented Sep 24, 2021

@Mm2PL I merged the PR. Please check the latest version.

@Mm2PL Mm2PL closed this as completed Sep 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants