Skip to content

Inconsistent casting/conversion errors #586

@juanitogan

Description

@juanitogan

Sometimes Consulo marks implicit Vector and Color conversion as an error. Sometimes not. I appears to be related to number of vars and/or uses. I think I've narrowed it down to this test code:

using UnityEngine;

//public class Test : ScriptableObject {
public class Test : MonoBehaviour {
	void whatever() {
		Vector3 v3;
//		Vector3 pos;
		Vector2 v2 = Vector2.zero;
		v3 = v2;
		v3 = v2;
		v3 = v2 + (2 * v2);
////		v2 = v3;
//		pos = v2 + (2 * v2);
////		v3 = v2 + (2 * v2);
		v3 = v2;

		thatV3(v2);


		Color c;
		Color32 c32 = new Color32(0,0,0,0);
		c = c32;
		Color cc;
		cc = c32;
	}

	void thatV3(Vector3 pv3) {
	}


	void bytetests() {
		byte b = 0;
		// Causes conversion error in Unity but no error in Consulo:
		//b = b | 1;
		// Causes unnecessary-cast warning in Consulo, no error in Unity:
		b = (byte)(b | 1);
	}
}

public class Enums {
	enum This {foo = 0}
	enum That {bar = This.foo | 2}  // Should allow.

	void nope() {
		//int i = This.foo | 2;  // Not allowed.
	}
}

Different lines show an error depending on what lines you comment and uncomment.

Also, note the cast warning on (byte) that doesn't belong there.

Also, note the error with | in an enum constructor (which is weird that enum constructors allow this -- found this error in some library code).

The above code compiles fine in Unity 2017.4.40f1 (default .NET 3.5 setting) but marks these errors in Consulo:

image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions