Skip to content

Crash: Unexpectedly found nil while unwrapping an Optional value #791

@jcmosc

Description

@jcmosc

I've attached a PR that adds a new test case to reproduce a crash when nesting multi root variadic views:
#790

OpenSwiftUICore/ForEach.swift:709: Fatal error: Unexpectedly found nil while unwrapping an Optional value

The nil value is passed into ViewList.applySublists() by VariadicView.Children.Element. Later ForEachState.applyNodes force unwraps the list parameter in various places on both the static and dynamic code paths. Though I can only reproduce this on the dynamic code path.

I'm not sure what the fix should be, i.e. whether a non-nil value should be passed in, or if ForEachState should expect nil values sometimes. Hopefully this repro helps you solve it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions