standalone-calls-do-not-write-to-nil.gd 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # https://github.com/godotengine/godot/issues/70964
  2. func test():
  3. test_construct(0, false)
  4. test_utility(0, false)
  5. test_builtin_call(Vector2.UP, false)
  6. test_builtin_call_validated(Vector2.UP, false)
  7. test_object_call(RefCounted.new(), false)
  8. test_object_call_method_bind(Resource.new(), false)
  9. test_object_call_ptrcall(RefCounted.new(), false)
  10. print("end")
  11. func test_construct(v, f):
  12. Vector2(v, v) # Built-in type construct.
  13. assert(not f) # Test unary operator reading from `nil`.
  14. func test_utility(v, f):
  15. abs(v) # Utility function.
  16. assert(not f) # Test unary operator reading from `nil`.
  17. func test_builtin_call(v, f):
  18. @warning_ignore("unsafe_method_access")
  19. v.angle() # Built-in method call.
  20. assert(not f) # Test unary operator reading from `nil`.
  21. func test_builtin_call_validated(v: Vector2, f):
  22. @warning_ignore("return_value_discarded")
  23. v.abs() # Built-in method call validated.
  24. assert(not f) # Test unary operator reading from `nil`.
  25. func test_object_call(v, f):
  26. @warning_ignore("unsafe_method_access")
  27. v.get_reference_count() # Native type method call.
  28. assert(not f) # Test unary operator reading from `nil`.
  29. func test_object_call_method_bind(v: Resource, f):
  30. @warning_ignore("return_value_discarded")
  31. v.duplicate() # Native type method call with MethodBind.
  32. assert(not f) # Test unary operator reading from `nil`.
  33. func test_object_call_ptrcall(v: RefCounted, f):
  34. @warning_ignore("return_value_discarded")
  35. v.get_reference_count() # Native type method call with ptrcall.
  36. assert(not f) # Test unary operator reading from `nil`.