huff-language / huff-docs

Extensive Huff Language Documentation, Tutorials, and Resources built with Vuepress and deployed at https://docs.huff.sh
https://docs.huff.sh
MIT License
36 stars 34 forks source link

Macro Arguments Cannot Be Opcodes #44

Closed Philogy closed 2 years ago

Philogy commented 2 years ago

In the Huff by Example section of the docs under Macros and Functions > Macros > Macro Arguments it is mentioned that "Macro arguments may be one of: label, opcode, literal, or a constant" however it doesn't currently seem to be possible to use opcodes as macro arguments (as of huffc v0.2.0, latest version at time of writing).

Specifically the lexer module of the Huff compiler does not recognize opcodes outside of the body of macros / functions at the moment (lexer reference). Personally I haven't dived deep enough into the codegen module so I'm unsure if there's any logic to support opcode args there already.

While this could be quite a useful feature in certain instances, it doesn't seem to be possible just yet.

clabby commented 2 years ago

Thanks for pointing this out! @abigger87 fixed this thismorning in https://github.com/huff-language/huff-rs/pull/188, I also fixed constants as macro args in https://github.com/huff-language/huff-rs/pull/190. Should be in tonight's nightly build, or for now, can update to the stage branch with huffup -b stage