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

structInit creates a "non-exist" but typeable constructor #9567

Open
kevinresol opened this issue Jun 12, 2020 · 3 comments
Open

structInit creates a "non-exist" but typeable constructor #9567

kevinresol opened this issue Jun 12, 2020 · 3 comments

Comments

@kevinresol
Copy link
Contributor

class Main{
	static function main() {
		$type(Foo.new);
	}
}

@:structInit
class Foo {
	@:optional var foo:Int;
}
src/Main.hx:3: characters 9-16 : Foo does not have a constructor
src/Main.hx:3: characters 9-16 : Warning : (foo : Null<Int>) -> Foo
@Simn
Copy link
Member

Simn commented Jun 12, 2020

We can change this to

src/Main.hx:3: characters 9-16 : Foo does not have a constructor
src/Main.hx:3: characters 9-16 : Warning : But if it did it would be
src/Main.hx:3: characters 9-16 : Warning : (foo : Null<Int>) -> Foo

@Simn
Copy link
Member

Simn commented Jun 14, 2020

The only thing I'm willing to change here is the "does not have" phrasing, because it's more about the fact that the generated constructor cannot be accessed explicitly.

The compiler tries to not completely die on every single error, so situations like this can easily occur with something like $type, and probably macros too.

@RealyUniqueName
Copy link
Member

the generated constructor cannot be accessed explicitly.

But why?

@RealyUniqueName RealyUniqueName added this to the Bugs milestone Jun 15, 2020
@Simn Simn modified the milestones: Bugs, Later Mar 24, 2023
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

3 participants