Re: Metatable __eq sometimes not called when JIT is on

  • From: Basurita <basuraparabarspi@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 18 Oct 2012 13:39:43 -0200

On 2012/10/18 08:11 , Nils Nordman wrote:
Hi,

I've run into a weird case with metatables and __eq, where it seems __eq is _sometimes_ not called when JIT is on. This manifests itself as erratically failing tests in my test suite. The setup is this:
[...]

Then when troubleshooting I added printouts to the __eq function to see whether it's called and what the return value is, and I added the following sanity check printout right below the above if statement:

  print('res ~= ' .. tostring(arguments[1] ~= arguments[i]))

What seems to happen when this fails is that

1) The __eq function is not invoked for the if conditional
2) The print statement below the if still causes the __eq function to be invoked 
correctly, and thus prints "res ~= false"

[...]

I seem to remember Mike saying that a print() call will abort the trace, so 
that trace won't be compiled (or something like that!!)
That may explain why things work correctly when you add the print(). He 
mentioned something along the lines of using io.write() instead...

Of course, this doesn't mean that your alleged bug doesn't exist. Just be 
careful when making tests with print()

BBB

Other related posts: