Repository navigation
Conversation
…s do
Convert.ChangeType() maps every Structure type to TypeCode.Object and
returns the argument unchanged, so a scalar passed to a suffix that
takes a BooleanValue, such as DOACTION("name", 1), reached the suffix's
cast and threw a bare InvalidCastException. Convert such arguments with
Convert.ToBoolean(), matching how conditions treat scalars and strings.
Arguments that still do not match a Structure parameter type now throw
KOSCastException instead of the InvalidCastException.
Fixes KSP-KOS#3006
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3006.
Currently, passing a non-boolean to a function that expects a boolean fails with
Specified cast is not valid. The docs say that a number should be usable where a boolean is expected.This PR converts to boolean the same way it's already done in logical conditions, and will still emit
Cannot use SOMETYPE where boolean is neededfor other types.AI Disclosure The code and commit message are by Claude Opus 5.5. I've tested in-game and confirmed the expected behavior, and I wasn't able to produce any unexpected side effects. I reviewed the code here and wrote this PR description based on my understanding of it.