Skip to content

Fix/ignore pure expr#47

Open
Davvex87 wants to merge 6 commits intoSomeRanDev:mainfrom
Davvex87:fix/ignore-pure-expr
Open

Fix/ignore pure expr#47
Davvex87 wants to merge 6 commits intoSomeRanDev:mainfrom
Davvex87:fix/ignore-pure-expr

Conversation

@Davvex87
Copy link

Fix for https://discord.com/channels/162395145352904705/1200065966445449286/1473062164435701905

Basically, inline function calls would still append the return expr into the code where the function was called from, even if the program didn't actually want to do anything with that return code, leading to errors in certain languages because the compiler didn't know what to do with them.

Heres an example with lua:

inline function add(arr:Array<T>, val:T):Int
{
  arr.push(val);
  return arr.length - 1;
}

var myArray = ["a", "b", "c"];
add(myArray, "d");

Before the fix:

local myArray = {"a", "b", "c"}
myArray[#myArray + 1] = "d"
#myArray - 1
-- ^^ This is wrong!!

After the fix:

local myArray = {"a", "b", "c"}
myArray[#myArray + 1] = "d"
-- notice how that last line is now gone

This fix also applies for blocks so it should be a universal fix for all situations.

@SomeRanDev
Copy link
Owner

Instead of having this for block expressions, could we make this preprocessor be for ALL hanging expressions with no side-effects?

Besides that, this is fantastic work!!

The basics should be finished with this commit, now the problem is figuring out how to properly handle blocks...
@skial skial mentioned this pull request Mar 4, 2026
1 task
Still not fully working though, next up i gotta figure out what do do with the final expression of a block
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

Successfully merging this pull request may close these issues.

2 participants