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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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_method_bind_validated(RefCounted.new(), false)
  10. print("end")
  11. func test_construct(v, f):
  12. @warning_ignore("unsafe_call_argument")
  13. Vector2(v, v) # Built-in type construct.
  14. assert(not f) # Test unary operator reading from `nil`.
  15. func test_utility(v, f):
  16. abs(v) # Utility function.
  17. assert(not f) # Test unary operator reading from `nil`.
  18. func test_builtin_call(v, f):
  19. @warning_ignore("unsafe_method_access")
  20. v.angle() # Built-in method call.
  21. assert(not f) # Test unary operator reading from `nil`.
  22. func test_builtin_call_validated(v: Vector2, f):
  23. @warning_ignore("return_value_discarded")
  24. v.abs() # Built-in method call validated.
  25. assert(not f) # Test unary operator reading from `nil`.
  26. func test_object_call(v, f):
  27. @warning_ignore("unsafe_method_access")
  28. v.get_reference_count() # Native type method call.
  29. assert(not f) # Test unary operator reading from `nil`.
  30. func test_object_call_method_bind(v: Resource, f):
  31. @warning_ignore("return_value_discarded")
  32. v.duplicate() # Native type method call with MethodBind.
  33. assert(not f) # Test unary operator reading from `nil`.
  34. func test_object_call_method_bind_validated(v: RefCounted, f):
  35. @warning_ignore("return_value_discarded")
  36. v.get_reference_count() # Native type method call with validated MethodBind.
  37. assert(not f) # Test unary operator reading from `nil`.