Skip to content
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

using STEERING in compiled function breaks things #1394

Closed
pellinor0 opened this issue Jan 27, 2016 · 1 comment
Closed

using STEERING in compiled function breaks things #1394

pellinor0 opened this issue Jan 27, 2016 · 1 comment
Labels
bug Weird outcome is probably not what the mod programmer expected. duplicate Will close because another PR or issue is the same. (please link to it when using this label)

Comments

@pellinor0
Copy link

A minimal example with two files, using KOS v0.18.2:
tmp.ks:

run once libtmp.
lock Steering to Up.

libtmp.ks:
function test { lock Steering to Up. }

Now I type in the terminal

switch to 0.
run tmp. // => runs fine
compile libtmp.
run tmp. // => Error
ProgramBuilder.ReplaceLabels: cannot add label steering'0-default, 
label already exists. Opcode: push $steering.
At tmp on archive, line 2.

It looks like mentioning 'Steering' in the function definition causes bad things, but only if the function is pre-compiled.

@hvacengi
Copy link
Member

This is a known issue with all locks. Due to how locks are compiled differently from variables, there is a small amount of run time information needed to properly handle the default values. Please see the following two issues for more information: #691 and #1253.

Currently, the only work around is to not use locks from within a compiled script. If you are building libraries, I would recommend that you split the lock-dependent code into a separate file from anything that might not need a lock.

It's on our road map to fix, but it's more complicated than my description makes it sound and we have not yet found a good way to implement the fix.

I'm going to close this as a duplicate, but please keep watching the other two issues referenced above to see when we have a solution enacted.

@hvacengi hvacengi added bug Weird outcome is probably not what the mod programmer expected. duplicate Will close because another PR or issue is the same. (please link to it when using this label) labels Jan 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Weird outcome is probably not what the mod programmer expected. duplicate Will close because another PR or issue is the same. (please link to it when using this label)
Projects
None yet
Development

No branches or pull requests

2 participants