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

Expression Parse funcs don't work well in certain contexts #173

Open
Demorome opened this issue Sep 15, 2023 · 0 comments
Open

Expression Parse funcs don't work well in certain contexts #173

Demorome opened this issue Sep 15, 2023 · 0 comments

Comments

@Demorome
Copy link
Contributor

Demorome commented Sep 15, 2023

I made the mistake of defining GetSelfAlt with DEFINE_CMD_ALT_EXP, meaning it uses the custom NVSE Expression Parser. The function works in basic contexts like calling it to store the result in a ref variable, but if you start using it in complex expressions it breaks down.

For example, this is broken as of writing:

if eval (GetSelfAlt != player)
   ; eval returns true even though player is the calling ref, and the "!=" operator code isn't even called at all
endif

But with regular GetSelf, which uses the default parser, this works as expected:

if eval (GetSelf != player)
   ; does not reach this space of code, as expected since GetSelf is not the player in this context
endif

Indeed, when switching GetSelfAlt to the regular parser, it starts working in this context again.

My guess is that the expression parser just doesn't work well with functions that have no args whatsoever, so I'll be simply sidestepping the issue since I couldn't find an obvious fix.

EDIT: This guess is wrong, I can replicate the issue with Call:

    if eval (player.Call ReturnCallingRefUDF != player)
        print "???????"  ; reached, wtf?
    endif 
scn ReturnCallingRefUDF
begin Function { }
    SetFunctionValue (GetSelf)
end

I've further studied some other cases, here are the results:

	if (GetSelfAlt_OLD != player)
		print "????? x 4"  ; does NOT print
	endif

	if ((GetSelfAlt_OLD) != player)
		print "????? x 5"  ; does NOT print
	endif

	if eval (GetSelfAlt_OLD != player)
		print "????? x 6"  ; prints
	endif

	if eval ((GetSelfAlt_OLD) != player)
		print "????? x 7" ; does NOT print
	endif

	if eval GetSelfAlt_OLD != player
		print "????? x 8" ; prints
	endif

GetSelfAlt_OLD here being the version that uses the expression parser.

@Demorome Demorome changed the title Expression Parse funcs don't work well if they have no args Expression Parse funcs don't work well in certain contexts Sep 15, 2023
Demorome referenced this issue Sep 22, 2023
Fixes situational bug in certain eval contexts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant