Skip to content

Drop Vec elements on scope exit and infer Option::None from call arguments (v0.1.19) - #18

Merged
Cod-e-Codes merged 2 commits into
mainfrom
fix/v0.1.19-vec-drop-option-none
Aug 14, 2026
Merged

Drop Vec elements on scope exit and infer Option::None from call arguments (v0.1.19)#18
Cod-e-Codes merged 2 commits into
mainfrom
fix/v0.1.19-vec-drop-option-none

Conversation

@Cod-e-Codes

Copy link
Copy Markdown
Owner

Summary

  • Codegen: Vec<T> scope-exit drop now drops remaining elements when T needs destruction, then ion_vec_free. This impacts any Vec<String>, Vec<Vec<U>>, or Vec of structs/enums with owned fields (previously the backing array was freed and elements leaked). Vec::get of such T hollows the slot (already specified as move-out). Vec::set drops the previous element. Vec<int> and other Copy elements are unchanged. Box<T> drops T before ion_box_free when T needs destruction; Box::unwrap still does not drop T.
  • Type checker: unannotated Option::None / other no-payload generic variants infer T from a call argument's parameter type (any position), matching return and struct-field positions. Unannotated let empty = Option::None still requires an annotation. This impacts passing Option::None or Result::Err(...) directly into a function.

Test plan

  • cargo fmt --check
  • cargo test
  • cargo clippy -- -D warnings
  • tests/test_runner.sh (Linux CI)
  • Example ion-build projects compile
  • Confirm Vec/Box string scope-drop tests plus LSan rows
  • Confirm take(Option::None) infers T; unannotated let empty = Option::None still errors

…ments.

Owned Vec and Box values leaked nested heap on drop, and unannotated Option::None could not use a function parameter as expected type.
Option wrapping a cyclic Vec was getting an unused static helper, which Linux gcc -Werror rejected.
@Cod-e-Codes
Cod-e-Codes merged commit 5036816 into main Aug 14, 2026
7 checks passed
@Cod-e-Codes
Cod-e-Codes deleted the fix/v0.1.19-vec-drop-option-none branch August 14, 2026 00:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant