Skip to content

Trait with class constant name conflict against enum case causes SEGV #21760

Closed

Description

@ndossche

Description

The following code:

<?php
trait X {
  public const Up = 1;
}

enum Direction {
  use X;

  case Up;
  case Down;
}

Resulted in this output:

SEGV

But I expected this output instead:

Not that

PHP Version

Reproduced on master but likely affects all versions since enums were added

Operating System

No response

Activity

  1. prateekbhujel commented on Apr 16, 2026

    @prateekbhujel
    Contributor

    Working on this in #21771 . The conflict can be rejected during trait constant binding before it reaches the enum case path that crashes.

  2. added a commit that references this issue on Apr 20, 2026
    2d651e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions