-
Notifications
You must be signed in to change notification settings - Fork 230
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
Global vars 'undefined' in local scope after running any program. #3102
Comments
What version of kOS are you on because this |
I'm running v1.4.0.0 |
I just realized i had config:clobberbuiltins set to true, so with that off the two points you mentioned no longer hold. The rest still applies though. |
Good to know I had to ask after the version because we have had a few people who have for one reason or another been on older versions without knowing it and updating fixed the issue. I was able to reproduce the error on my end though my test cases ended up looking like this:
and
and
In my tests the log was only run once and restarts occurred between attempts to remove the added global vars.
when they should be printing
I also tested running the tests as files and not commands typed into the terminal and got the expected result. |
Actually even with clobberbuiltins enabled this
should still not print
which prints |
the abnormal behavior in this case
is that it prints Which some what counterintuitively means that means that
is behaving correctly and the other case does not. But as both cases involve clobbering built ins the behavior will always be rather abnormal as it was never intended that you could clobber built ins hence the default setting to prevent it. |
In a local scope directly after running a program all vars are 'undefined'. This does happen no matter what program you run. I stumbled over this using an if-block after running a program, but for simplicity i could reduce it further to this:
Throws an Error:
Undefined Variable Name 'time'.
Weirdly even global vars defined in that local scope are unknown aswell, but local vars work:
Undefined Variable Name 'x'.
1
edit: The following only worked due to config:clobberbuiltins being set to true, so those points no longer apply:
Further, it is even possible to overwrite any var globally on the core the code is run on until it is rebooted:Time for coffee
After doing that, 'time' in this case behaves like any other var created by the user. It can even be unset.As far as i can tell this works with any and all vars, even fun stuff like that:Kerbin has a sea-level circumference of 3769911.2 m.
Kerbin has a sea-level circumference of 4200000 m.
The text was updated successfully, but these errors were encountered: