HaxeFoundation / HaxeFoundation/haxe

Matching same enum twice seems to duplicate the default case.

Open
#12,120 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Minmal example

import haxe.ds.Option;

class Test {
  static function main() {
    var a = [
      Live,
      Offline({ vct: None, ot: Some('foo') }),
      Offline({ vct: Some('bar'), ot: None }),
    ];
    
    switch a[Std.random(a.length)] {
      case Offline({ vct: Some(v) }): trace('1 $v');
      case Offline({ ot: Some(v) }): trace('2 $v');
      case _:
      	trace("default!");
    }
  }
}
        
enum A {
  Offline(v:{ vct:Option<String>, ot:Option<String> });
  Live;
}

You'll find the code generated for trace("default!"") twice in the output, both with Haxe 4 and nighly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the minimal Haxe example from the issue with Haxe 4 and the nightly compiler, then inspect the generated output around the two copies of trace("default!"). Done means matching the same enum twice no longer emits duplicate default-case code.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.