haxe icon indicating copy to clipboard operation
haxe copied to clipboard

duplicate field access errors in some cases

Open nadako opened this issue 5 years ago • 2 comments

class A {
	static var A:Int;
}

class Main {
	static function main() {
		A.A;
	}
}

gives

src/Main.hx:7: characters 5-6 : Cannot access private field A
src/Main.hx:7: characters 5-6 : Cannot access private field A

That's the case even in haxe 3.4.7, but it now also happens for lowercase fields, since the merge of module-statics and it's the reason for the current CI failures.

I believe the issue is caused by the fact that field access is done twice, because we do it extra time to get a Not_found error when resolving dot path:

https://github.com/HaxeFoundation/haxe/blob/01cfe550b9da7b50c1face9285e4612073653ae8/src/typing/typerDotPath.ml#L102

It's a bit tricky to fix and will likely require refactoring TyperDotPath somehow again...

nadako avatar May 16 '20 10:05 nadako

I just tried this and only get the error message once. Could you check again?

Simn avatar Jun 04 '20 06:06 Simn

I hacked it around in a very ugly way, see linked commit above ;)

nadako avatar Jun 04 '20 06:06 nadako