Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Missing and Undefined Macros Args Raise No Errors #290

Open
Philogy opened this issue Jul 31, 2023 · 0 comments
Open

Missing and Undefined Macros Args Raise No Errors #290

Philogy opened this issue Jul 31, 2023 · 0 comments
Labels
bug Code Smells

Comments

@Philogy
Copy link
Contributor

Philogy commented Jul 31, 2023

Huff version: huffc 0.3.2 (nightly: 813b6b6)

Reproducing

Example 1

#define macro LE_MACRO(a) = takes(0) returns(2) {
    <a> dup1
}

#define macro MAIN() = takes(0) returns(0) {
    LE_MACRO()
}

Output (huffc -r ./test-empty.huff): 80 (Equivalent to compiling just dup1)

Expected Output: Compiler Error indicating that LE_MACRO is missing it's parameter a at the specific line in MAIN

Example 2

#define macro LE_MACRO() = takes(0) returns(2) {
    <b> pop
}

#define macro MAIN() = takes(0) returns(0) {
    LE_MACRO()
}

Output (huffc -r ./test-empty.huff): 50 (Equivalent to compiling just pop)

Expected Output: Compiler Error indicating that the referenced macro parameter <b> in LE_MACRO is undefined

Description

If a macro parameter is missing / undefined the current compiler will simply skip it, potentially resulting in invalid bytecode. This particularly becomes an issue when you're e.g. refactoring larger files where it may be hard to notice whether or not you forgot to add a certain parameter. Furthermore, I can imagine few situations where you'd want macro arguments to be optional as they'll modify the stack and meaning of subsequent instructions.

@Maddiaa0 Maddiaa0 added the bug Code Smells label Aug 15, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
bug Code Smells
Projects
None yet
Development

No branches or pull requests

2 participants