Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum abstract not checked #11577

Open
ncannasse opened this issue Feb 14, 2024 · 5 comments
Open

Enum abstract not checked #11577

ncannasse opened this issue Feb 14, 2024 · 5 comments

Comments

@ncannasse
Copy link
Member

Surprisingly the following compile while it shouldn't ( T should be Int on step++)

enum abstract T(Int) {
   var Start;
   var End;
}

class Test {
  
  static var step(default,set) : T;
  
  static function set_step(s:T) { step = s; return s; }
  
  static function main() {
     step++;
  }
}
@Simn
Copy link
Member

Simn commented Feb 14, 2024

It's even worse:

class Main {
	static var step(default, set):String;

	static function set_step(s:String) {
		step = s;
		return s;
	}

	static function main() {
		step++;
	}
}

(Edit: Well that would actually make some sense with String and + specifically, but it admits any type here it seems.)

Simn added a commit that referenced this issue Feb 14, 2024
@ncannasse
Copy link
Member Author

Is it a regression ? It seems quite bad, we want the fix to be merged asap @yuxiaomao :D

@Simn
Copy link
Member

Simn commented Feb 14, 2024

According to my brief try.haxe investigations it was a regression from 4.1 to 4.2, so quite old.

I'll pull the linked fix and will keep this issue open as a reminder to add tests.

Simn added a commit that referenced this issue Feb 14, 2024
@kLabz kLabz added this to the 4.3 Hotfix candidates milestone Feb 14, 2024
@yuxiaomao
Copy link
Contributor

The case of string++ can still compile without warning. Is that normal?

@Simn
Copy link
Member

Simn commented Feb 16, 2024

Good question... when accessors are involved, a++ is pretty much treated like a += 1 and this has always been admitted for operands of type String and Int. But it doesn't really look like it should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants