asar icon indicating copy to clipboard operation
asar copied to clipboard

Variadic macro arguments are not resolved in `elseif` statements

Open exodustx0 opened this issue 9 months ago • 3 comments

asar 1.90
macro foo(...)
	if 0 == 1
		print "no"
	elseif <...[0]> == 42
		print "yes"
	else
		print "bug"
	endif
endmacro

%foo(42)

This patch prints bug, as well as an error that elseif <...[0]> == 42 contains an invalid number, <...[0]> specifically.

https://github.com/RPGHacker/asar/blob/9bd5a49ef0f2965cd8c5b17e9de687c5df854783/src/asar/assembleblock.cpp#L1000-L1011

The above was an attempt at fixing the overarching bug, but it does not account for this condition in replace_macro_args() which guards variadic argument resolving:

https://github.com/RPGHacker/asar/blob/9bd5a49ef0f2965cd8c5b17e9de687c5df854783/src/asar/macro.cpp#L277-L286

I'm not sure at a glance what the solution here would be, but given that this is already a hacky bit of code that fixes most of the overarching bug, that doesn't surprise me.

exodustx0 avatar Apr 08 '25 21:04 exodustx0

does not reproduce in asar 2.0

why are you reporting so much stuff against 1.9 btw?

trillllian avatar Apr 08 '25 21:04 trillllian

to elaborate a bit: 2.0 is technically still beta, but not because it's less stable than 1.9, there's just a bit more stuff i want to get done before calling it 2.0. and well, looking at the bug reports it seems like 2.0 might be more stable than 1.9 (though idk, maybe you'd just find different bugs there).

there's a bunch of refactorings in 2.0 that make development easier (for me at least), so i don't have much motivation to backport bug fixes to 1.9 unless someone makes a pull request or it's really critical.

trillllian avatar Apr 08 '25 21:04 trillllian

I do want to contribute PRs for the bugs I've reported at some point; for a few I've already drawn out the complete fix in the bug report itself or the comments on it. I'd just need to figure out how to get the whole unit tests system working first though, unless it's a "to hell with unit tests" situation, but that's not my call to make. I can read and write C++ just fine, I'm just extremely slow to figure out non-trivial C++ compiler/build system/dev environment wrangling, as they tend to be unintuitive as all get-out to me.

For the same above reason, I have not yet looked into giving 2.0 a go, but also because I'm working on a personal to-be-open-source project and want to depend on a non-beta stable release, so I've not yet had much reason to look into 2.0. Then again, I imagine most still work with 1.91 too, what with SMWCentral's hosting of it.

But if 2.0 is around the corner, I might as well wait for that, or, assuming I can find my way in the 2.0 codebase (and dev env) and you'll have me, maybe help move things along.

exodustx0 avatar Apr 08 '25 21:04 exodustx0