Skip to content

Fix/ignore pure expr#47

Merged
SomeRanDev merged 9 commits intoSomeRanDev:mainfrom
Davvex87:fix/ignore-pure-expr
Mar 22, 2026
Merged

Fix/ignore pure expr#47
SomeRanDev merged 9 commits intoSomeRanDev:mainfrom
Davvex87:fix/ignore-pure-expr

Conversation

@Davvex87
Copy link
Contributor

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
Davvex87 added 3 commits March 8, 2026 22:43
Still not fully working though, next up i gotta figure out what do do with the final expression of a block
@Davvex87
Copy link
Contributor Author

Well this was hard to implement... but its done!
I did some tests with my reflaxe.lua library and everything worked correctly, hopefully I didn't miss anything.

@SomeRanDev
Copy link
Owner

Thanks for all the hard work! I didn't realize it would be that much more work 😭

You failed the test_runtime because your code doesn't pass null-safety. You can simply run haxe DevEnv.hxml in your local Reflaxe directory to test this yourself!

@Davvex87
Copy link
Contributor Author

Davvex87 commented Mar 22, 2026

Implementing the code wasn't even that hard, but understanding and translating the original compiler from ocaml was super time consuming 🥀

@SomeRanDev SomeRanDev merged commit 161cdb3 into SomeRanDev:main Mar 22, 2026
5 of 6 checks passed
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