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

Invalid operation on setter when using null field access #11592

Closed
Jarrio opened this issue Feb 23, 2024 · 2 comments
Closed

Invalid operation on setter when using null field access #11592

Jarrio opened this issue Feb 23, 2024 · 2 comments

Comments

@Jarrio
Copy link

Jarrio commented Feb 23, 2024

Demo: https://try.haxe.org/#871345F4

If you remove the ? from the line things work fine. I'm not exactly sure what the issue is specifically, but, the error should probably be clearer as well

Code:

class Test {
  static function main() {
    var bar = new Bar();
    trace(bar.stuff);
  }
}

class Bar {
  var foo = new Foo();
	var values(get, never):Data;
  function get_values() {
		return foo?.value;
  }
  
  public var stuff(get, set):Float;
  function get_stuff() {
		return values?.stuff;
  }
  
  function set_stuff(value:Float) {
		return values?.stuff = value; // error here
  }
  
  public function new() {}
}

class Foo {
  public var value:Data = new Data(32);
  public function new() {}
}

class Data {
	public var stuff:Float;
  public function new(data) {
		this.stuff = data;
  }
}
@RblSb
Copy link
Member

RblSb commented Feb 24, 2024

Already fixed in dev, see #11379

@Jarrio
Copy link
Author

Jarrio commented Feb 24, 2024

Already fixed in dev, see #11379

Ah yes, my bad I should have checked. Thanks!

@Jarrio Jarrio closed this as completed Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants