Page 1 of 1

SC load with fc bug on calling sub

Posted: 16 Sep 2019 08:11
by fishgod
The resource-type fc introduced in v20.40.0005 causes problems when calling a sub in the loaded script when its loaded from cache:

Execute this script load-1.xys

Code: Select all

"Test Cached Load"
  load 'load-2.xys', , 'fc';
  load 'load-2.xys', , 'fc';
load-2.xys

Code: Select all

"Second script : main"
  sub '_sub';

"_sub"
  msg "First Time OK, second time Bug!";

Re: SC load with fc bug on calling sub

Posted: 16 Sep 2019 12:01
by admin
Fixed in next beta.

Re: SC load with fc bug on calling sub

Posted: 16 Sep 2019 18:52
by Filehero
Hi Don,

could it be that this fix breaks the/a check for existing user functions?

20.40.0003 is fine, 20.40.0006 ist raising a script error for the very first time complaining for a "already existing user function".
Because the scripts and functions involved are providing my generic menu generator I hadn't time for a detailed analysis (or a screenshot), only for a simple rollback.


Thanks,
Filehero

admin wrote: ↑16 Sep 2019 12:01 Fixed in next beta.

Re: SC load with fc bug on calling sub

Posted: 16 Sep 2019 19:10
by admin
No, this isn't the fix. It's a new warning when you try to overwrite your own functions. Looks like something is wrong with your script.

Re: SC load with fc bug on calling sub

Posted: 16 Sep 2019 19:16
by Filehero
Hmm, I never overwrite existing functions. Needs more time to check.

Thanks for your quick reply.

Re: SC load with fc bug on calling sub

Posted: 16 Sep 2019 19:19
by fishgod
The new warning is a result of the discussion from this thread: viewtopic.php?f=3&t=20889&start=15#p172617

I also get this warning with my script, everything looks correct so far. Let me try to build a minimal example that causes the behaviour.

Re: SC load with fc bug on calling sub

Posted: 16 Sep 2019 19:37
by Filehero
Just a first idea:

I have a script (script A) which references another one (script B, my core library) by include_once.
Within A I build up the source code for a third one (script C) which is finally run from A using load($mscript, , "s");.
Now, since the on-the-fly script C also references B I suspect this to be the cause of the problem somehow (nested scripts and includes).

But I have no further time right now, hope to find some tomorrow.

Re: SC load with fc bug on calling sub

Posted: 27 Sep 2019 18:50
by Filehero
This fixed my issue. What a relief - I got my core script functionality back. :D

Code: Select all

v20.40.0016 - 2019-09-25 13:12
    * Scripting: Removed that "A user function of the same name already exists!" 
      error message (added in v20.40.0006 - 2019-09-16 16:33). The script is not 
      terminated anymore, and the function in question is silently ignored (any 
      previous function of the same name is not overwritten by it).
      Reason: The error message was probably poorly implemented. It came up too 
      often and destroyed working user scripts.
I should have some drinks on that. :mrgreen:

Re: SC load with fc bug on calling sub

Posted: 27 Sep 2019 20:22
by Filehero
Hi Don,

have you done a "complete rollback"?

With some scripts I still see hickups, but before spending more time I want to be sure there isn't a more time-saving solution. :whistle:

Thanks,
Filehero

Re: SC load with fc bug on calling sub

Posted: 27 Sep 2019 20:30
by admin
Pretty complete. There was a fix concerning dupe user functions that I left in, of course. If your script relies on user functions overwriting each other then you have a problem. :)

Re: SC load with fc bug on calling sub

Posted: 27 Sep 2019 21:19
by Filehero
:mrgreen:

Ok, the mysterious overwritten function. Next week I'll find and "kill" it. :maf:
admin wrote: ↑27 Sep 2019 20:30 Pretty complete. There was a fix concerning dupe user functions that I left in, of course. If your script relies on user functions overwriting each other then you have a problem. :)