[ERROR] line 155 Collision.hx:155: characters 11-31 : Warning : Structures with new are deprecated, use haxe.Constraints.Constructible instead
Closed this issue · 11 comments
as the tile says.
this is just setting it up as normal, nothing has actually been put in apart from imported
Which version of haxe are you using? The code is based on the documentation example.
ah must be because im using latest 3.3.0 RC1
Maybe around line 154 try something like:
#if (haxe_ver >= 3.3)
private typedef Constructible = haxe.Constraints.Constructible;
#else
private typedef Constructible = {
public function new():Void;
}
#endif
I'm not sure if it will like this.
Not sure why it says both error and warning in the title, but does compilation stop at this warning?
yeah it does stop
latest error with change
../Sources/differ/Collision.hx:159: characters 36-66 : Invalid number of type parameters for haxe.Constructible
which is the private typedef Constructible = haxe.Constraints.Constructible;
yea figures, could you test with this replacing the entire bottom section?
//Internal helpers
#if (haxe_ver < 3.3)
private typedef Constructible = {
public function new():Void;
}
#end
/**
A result set container.
Items in the container are preallocated, then pulled out and updated.
The container will behave like a regular container, where iterating,
and get will only return values from the valid set. Pushing items
will increase the valid set.
*/
@:generic
#if (haxe_ver >= 3.3)
class Results<T:haxe.Constraints.Constructible<Void->Void>> {
#else
class Results<T:Constructible> {
#end
public var length (get, never) : Int;
public var total (get, never) : Int;
//internal
var items:Array<T>;
var count:Int = 0;
/** Create a new set of results.
Preallocates `size` items into the list. */
public function new(size:Int) {
items = [for (i in 0...size) new T()];
}
/** Add an item to the container. */
inline public function push(value:T) : Void {
items[count] = value;
count++;
} //push
/** Get the item at the given index.
If the index is < 0 and > length-1 it returns null; */
inline public function get(index:Int) : T {
if(index < 0 && index > length-1) return null;
return items[index];
} //get
/** Grabs the last item from the cache to reuse.
If there are no free items, it adds a new one.
Typically internal use. */
inline public function pull() : T {
//no more?
if(items.length == count) items.push(new T());
//return the last item
return items[count];
} //pull
/** Clear the container, which sets the length to 0.
This keeps the cached items but won't return them
while iterating or accessing them.
Returns `this` for convience. */
inline public function clear() : Results<T> {
count = 0;
return this;
}
/** Returns an iterator over the valid items in this set. */
inline public function iterator() : ResultsIterator<T> {
return new ResultsIterator<T>(this);
}
// getters
inline function get_length() : Int return count;
inline function get_total() : Int return items.length;
} //Results
@:generic
#if (haxe_ver >= 3.3)
class ResultsIterator<T:haxe.Constraints.Constructible<Void->Void>> {
#else
class ResultsIterator<T:Constructible> {
#end
var index: Int = 0;
var results: Results<T>;
public function new(_results:Results<T>) {
index = 0;
results = _results;
}
public inline function hasNext() {
return index < results.length;
}
public inline function next() {
return results.get(index++);
}
} //ResultsIterator
ok. that seems to have stopped the error. ;)
cheers
I've pushed to master if that's more convenient. Thanks for the report.
no worries. cheers for the fix ;)
This error still exists in the version available via haxelib (checked on haxe 4.0.5). It seems github version works fine. It's a bit inconvenient, is the haxelib edition getting updated?
And done, haxelib is updated.