Menu

#107 Different behavior if calling GetValue before SetValue on table

None
closed
nobody
None
5
2021-11-26
2021-11-25
Omega
No

Tested with squirrel 3.1 and sqrat 0.9.2.

When calling GetValue before SetValue there is different behavior. Either it doesn't return the table or it never set it properly. See attached example code.

2 Attachments

Discussion

  • Wizzard

    Wizzard - 2021-11-26

    Can you tell me the output of your example? I'm willing to accept a pull request submitted by you that fixes this behavior and try to help you work through it if needed.

     
  • Wizzard

    Wizzard - 2021-11-26
    • status: open --> pending
    • Group: -->
     
  • Omega

    Omega - 2021-11-26

    Hi Wizzard. I was able to isolate the problem in the code I was writing to this behavior in Sqrat/squirrel. I haven't taken the time yet to find and fix the issue. I was hoping you had some idea what might be going wrong. I can keep looking at it if you like. Below is the output I got from the test case. In both cases it will call the SetValue but only case A returns the table in the last GetValue call (the one after SetValue).

    Test Case A
    ===========
    Set
    Get OK
    
    Test Case B
    ===========
    Set
    Get FAILED
    
     
  • Omega

    Omega - 2021-11-26

    Hi Wizzard, it looks like I didn't read the API documentation very well. It's setting the error in the VM and it needs to be cleared. Clearing the error between the GetValue and SetValue fixed it:

    Sqrat::Error::Clear(vm);
    

    It's a bit unfortunate you have to know to do this but no change to the code should be needed.

     
  • Wizzard

    Wizzard - 2021-11-26
    • status: pending --> closed
     
  • Wizzard

    Wizzard - 2021-11-26

    Glad you got it worked out! The way I chose to do errors is pretty weird, but I was trying to make it backwards compatible because Sqrat started off with no error checking at all!
    (it actually works quite a bit faster too when you compile with error checking off)

     

    Last edit: Wizzard 2021-11-26

Log in to post a comment.