Skip to content

Ambiguous systems can accidentally be reported as non-ambiguous due to an automatically inserted apply_deferred. #23843

@andriyDev

Description

@andriyDev

Example:

fn a() {}
fn b(_: Query<&mut Foo>) {}
fn c(_: Commands) {}
fn d(_: Query<&mut Foo>) {}

app.add_systems(Update, (a, b).chain());
app.add_systems(Update, (c, d).chain());

In this example, systems b and d are ambiguous. However, since c has commands, an apply_deferred stage will be inserted between c and d. This accidentally resolves the ambiguity between b and d since b and d are now separated by an apply_deferred.

If however we add mut commands: Commands to a, b and d will now be reported as ambiguous! This is confusing since we never touched b or d! In fact, user code (not just internal Bevy code) can induce ambiguity to appear just by add before/after constraints on Bevy internal systems.

We should at least get Bevy internals to be resilient to this!

Discord discussion: https://discord.com/channels/691052431525675048/749335865876021248/1491243586082181312

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-BugAn unexpected or incorrect behaviorD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    Status

    Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions