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
Fix builtin item metatable. #2328
Conversation
@bell07 Can you retest this? |
Tested, works as expected with wielded_light |
@sofar what is your intention for this, merging to master and stable-5? I don't know how to do that so will leave merging to others. |
The right thing to do would be:
|
That sounds fine to me. |
The related line to this issue (why it did work previosly) in minectest core is the |
IRC comments by p_gimeno http://irc.minetest.net/minetest-dev/2019-04-03#i_5524097 21:08 p_gimeno I understand what game#2328 is doing, but not quite why it's a problem (I always prefer metatables to be in a dedicated table anyhow, but I fail to see why it's a problem in this case; the justification in game#2286 is fuzzy to me: "The reason for this fix is the wrong metatables usage that take nil values for some conditions" |
Using the same table as metatable to himself breaks redefinition chains. Sample code:
Output:
As you see the references to a and to b gets lost. Depending on mods loading order maybe the a and c is broken, not predicteable |
@bell07 to be clear, are you saying this PR is fine and needed? |
The PR is still highly recommended but not mandatory. Currently no redefinition chain is implemented in Minetest Game, but to be fair for other mods, please apply the patch. |
IRC http://irc.minetest.net/minetest-dev/2020-02-13 11:18 p_gimeno I still fail to see why #2328 is a problem. The example reported by bell07 is user error. http://www.formauri.es/personal/pgimeno/pastes/mtg2328.lua works fine. |
I think the right way is to replace __index by function that write a deprecation warning to the log but still have the meta functionality. Then in second step (after next release) the __index should be removed. |
Will setup this change as PR tomorrow: https://github.com/bell07/minetest/commit/0d465a355b4ea3883a5cb2da5272a994bf85eb2b |
Thanks, and sorry that most core devs do not understand this. |
I try it ;-) minetest/minetest#9407 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at this again today and while both solutions work, not reusing the whole table as metatable looks like a cleaner solution to me.
Doesn't the __index need to be removed, above? |
This has sufficient approval to be merged, but it looks like there are still some doubts. |
If I should (attempt to) explain the issue again, let me know. Current state is two merge requests:
The merging order does not matter. If the 1 is merged at the first, the warning is printed to the log till 2 is merged. If both changes are merged, in third step the deprecation/compatibility code from 1 can be fully removed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped items still work. LGTM.
This is a cleaned up version of #2286 , applied on top of
stable-5
.