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

func()++ crashes with malformed assignment #9040

Closed
2 tasks done
tinkerer-red opened this issue Jan 16, 2025 · 3 comments
Closed
2 tasks done

func()++ crashes with malformed assignment #9040

tinkerer-red opened this issue Jan 16, 2025 · 3 comments
Labels
runner-bug In-game bugs with the "GameMaker Studio 2" runtimes

Comments

@tinkerer-red
Copy link

Description

preffix and suffix -- and ++ require writing to the variable even when the variable is not writable. This was discovered in a test suit for the testing framework. This bug report was requested for submission.

It appears this should work for gmrt and treat the return from the function as a temporary variable. in the following example:

var _func = function(){ return 0 }
t = ++_func()
// t should equal 1

Reasonable to assume this would be a GMRT based change

Expected Change

No response

Steps To Reproduce

example:
https://api.gamemaker.io/api/github/downloads/3c0f6d70-0c9d-43d8-bcda-bf127e84ab4b

var _func = function(){ return 0 }
var t;

t = _func()  
t = ++_func()
t = _func()++
t = --_func()
t = _func()--

This is an example directly from the Test framework

addFact("Function Call Unary Update", function() {
	var _func = function(){ return 0 }
	
	assert_equals(_func()  , 0, "Function call get failed.");
	assert_equals(++_func(), 0, "Function call PlusPlus Suffix failed.");
	assert_equals(_func()++, 2, "Function call PlusPlus Prefix failed.");
	assert_equals(--_func(), 2, "Function call MinusMinus Suffix failed.");
	assert_equals(_func()--, 0, "Function call MinusMinus Prefix failed.");
	assert_equals(_func()  , 0, "Function call get failed.");
});

How reliably can you recreate this issue using your steps above?

Always

Which version of GameMaker are you reporting this issue for?

2024.11.0 (Monthly), 2024.1100 (Betas)

Which platform(s) are you seeing the problem on?

Windows

Sample Package Attached?

  • I have attached my bug package

Sample Project Added?

  • I have included a small sample project
@tinkerer-red
Copy link
Author

As a note this is likely related to this bug report: #7799
Leaving it to the team to decide weather to keep that as two separate bug reports, or to unify them. If they are unified then the comment in the test for this should be updated to include the correct bug ID: YoYoGames/GM-TestFramework@470d9dd

@rwkay
Copy link

rwkay commented Jan 16, 2025

OK this makes no sense, what does func()++ and variants even mean, there is no variable to increment - GML has no references so the function cannot return a reference that is then incremented.

It is a compile error and should stay as such.

@stuckie
Copy link

stuckie commented Jan 17, 2025

Closing as above

@stuckie stuckie closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Team Workload Jan 17, 2025
@iampremo iampremo moved this from Done to Not a bug in Team Workload Jan 17, 2025
tinkerer-red added a commit to tinkerer-red/GM-TestFramework that referenced this issue Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
runner-bug In-game bugs with the "GameMaker Studio 2" runtimes
Projects
Status: Not a bug
Development

No branches or pull requests

3 participants