Repository navigation
Fix List.Add() returning the list without the added value - #80
Merged
Merged
Conversation
Author
|
Hi @siimav, a gentle bump, and a short summary in case it's easier to look at the four together. No rush at all.
They don't touch the same files, so they can be merged in any order. I've also been playing my own career with all four on top of master, with no Contract Configurator errors in the log so far. If you'd rather have any of them changed, split or squashed, just let me know. |
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.
Add()on a list never adds anything:ToList()makes a copy, the value goes into the copy, and the original list is returned. So[Kerbin].Add(Mun)is still[Kerbin], andAddon a null list returns an empty list. This changes it to copy first and then add, the same wayExcluderight below it works, so the input list is still left untouched.I ran into it through RoverScience's rover contract, which relies on
Add()(linuxgurugamer/RoverScience-Continued#11). The pattern also shows up intest/Expression.cfg([Kerbin].Concat([Mun]).Add(Minmus).Random()), where Minmus can never be picked.Tested the old and new lambda in isolation:
[Kerbin].Add(Mun)gave[Kerbin]before and[Kerbin, Mun]after. The patched build loads in KSP 1.12.5 with about 330 contract types from several packs and no errors. In game, a test contract group with[Kerbin].Add(Mun)shows a count of 2 in the debug window (Alt+F10).