You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I call .CanInstantiate() on a CSharpScript object it returns true even though it can't be instantiated via .New() when the class is abstract. I get a runtime exception: MemberAccessViolation: Cannot create an abstract class. (see attachment)
I would expect that .CanInstantiate() only returns true when I actually can instantiate it.
Steps to reproduce
Get some kind of CSharpScript (e.g. via ResourceLoader)
The script system doesn't seem to have any concept of abstractness, and the function doesn't test anything like that in CSharpScript, so seems like a missing functionality, would be supported if abstract classes were added to GDScript probably:
Also IIRC there was an issue for pretty much the same thing with gdscript where for core types can_instantiate returns true, but it is not actually possible to do so, can't find it rm tho,
I can understand that GDScript does not support the concept of abstraction yet. But to be honest when a method says Returns true if the script can be instantiated. but I can't instaniate it I would expect that the CSharpScript implementation overrides it in a way that the abstract marking is checked. Because this way the API just delivers a wrong information.
So I think it more a bug seen from this perspective.
Godot version
v4.1.beta1.mono.official [828ec2c]
System information
Windows 11
Issue description
When I call
![image](https://private-user-images.githubusercontent.com/7323098/245932378-b57dde1d-bc60-48b9-a21b-24838dd3a519.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1NzAzMTIsIm5iZiI6MTczOTU3MDAxMiwicGF0aCI6Ii83MzIzMDk4LzI0NTkzMjM3OC1iNTdkZGUxZC1iYzYwLTQ4YjktYTIxYi0yNDgzOGRkM2E1MTkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMjE1MzMyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzQyMDI4YWI1MTBhOTRkMDY1YzcxNjkwMjFkZTMyMWI1NmRlN2VjYmE5YzZlNjI5NjIxZDczY2I3MGMzNWIxOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.kFABi75o_dcQVLT9X3xYHj3b2zCjXOCm2FOqjHf-sLw)
.CanInstantiate()
on a CSharpScript object it returns true even though it can't be instantiated via.New()
when the class is abstract. I get a runtime exception:MemberAccessViolation: Cannot create an abstract class.
(see attachment)I would expect that
.CanInstantiate()
only returns true when I actually can instantiate it.Steps to reproduce
.CanInstantiate()
on it / print it.New()
on itMinimal reproduction project
CanInstantiateBug.zip
The text was updated successfully, but these errors were encountered: