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

[cs] -D erase-generics problem #3949

Closed
nadako opened this issue Mar 2, 2015 · 5 comments
Closed

[cs] -D erase-generics problem #3949

nadako opened this issue Mar 2, 2015 · 5 comments
Assignees
Labels
bug platform-cs Everything related to c#

Comments

@nadako
Copy link
Member

nadako commented Mar 2, 2015

var arr = [1,2,3];
arr;
cs.system.Array.Sort(@:privateAccess arr.__a, 0, arr.length);

generates

 global::System.Array.Sort(((int[]) (((object[]) (arr.__a) )) ), ((int) (0) ), ((int) (arr.length) ));

which then fails to compile by c# compiler

@nadako nadako added bug platform-cs Everything related to c# labels Mar 2, 2015
@nadako nadako added this to the 3.2 milestone Mar 2, 2015
@waneck waneck modified the milestones: 3.3, 3.2 Mar 15, 2015
@Simn Simn modified the milestones: 3.3.0-rc1, 3.4 Feb 23, 2016
@Simn Simn modified the milestones: 3.4, 4.0 Jan 9, 2017
@waneck
Copy link
Member

waneck commented Jun 25, 2017

I don't think there's anything we can do in here. It's the age-old problem of dealing with type parameters and native arrays on java/c#. Any ideas, @nadako ?

@nadako
Copy link
Member Author

nadako commented Jun 25, 2017

Not really...

@Simn Simn modified the milestones: Release 4.0, Bugs Apr 17, 2018
@RealyUniqueName
Copy link
Member

RealyUniqueName commented Aug 20, 2019

Blocks #5749

import cs.NativeArray;

class Main {
	public static function main() {
		var a = new Arr<Int>();
		test(a.arr[0]);
	}

	static public function test(i:Int) {}
}

class Arr<T> {
	public var arr:NativeArray<T>;
	public function new() {}
}
$ haxe -main Main -cs bin -D erase-generics
haxelib run hxcs hxcs_build.txt --haxe-version 4000 --feature-level 1
Note: dmcs is deprecated, please use mcs instead!
src/Main.cs(30,33): error CS0030: Cannot convert type `object[]' to `int[]'
Compilation failed: 1 error(s), 0 warnings

Generated cs for the failing line:

global::Main.test(((int[]) (a.arr) )[0]);

We need to generate (int)(a.arr[0]) Instead of casting a native array itself.

@RealyUniqueName
Copy link
Member

I kind of "fixed" this for NativeArray specifically. But fixing it in general seems impossible.

@RealyUniqueName RealyUniqueName modified the milestones: Release 4.0, Backlog Aug 23, 2019
@Simn Simn removed this from the Backlog milestone Mar 24, 2023
@Simn
Copy link
Member

Simn commented Mar 24, 2023

Closing old C# issue that won't be addressed.

@Simn Simn closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug platform-cs Everything related to c#
Projects
None yet
Development

No branches or pull requests

4 participants