mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
GDScript: Allow constant expressions in annotations
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
var num := 1
|
||||
|
||||
@export_range(num, 10) var a
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1,2 @@
|
||||
GDTEST_ANALYZER_ERROR
|
||||
Argument 1 of annotation "@export_range" isn't a constant expression.
|
||||
@@ -0,0 +1,10 @@
|
||||
const BEFORE = 1
|
||||
|
||||
@export_range(-10, 10) var a = 0
|
||||
@export_range(1 + 2, absi(-10) + 1) var b = 5
|
||||
@export_range(BEFORE + 1, BEFORE + AFTER + 1) var c = 5
|
||||
|
||||
const AFTER = 10
|
||||
|
||||
func test():
|
||||
pass
|
||||
@@ -0,0 +1 @@
|
||||
GDTEST_OK
|
||||
@@ -1,12 +1,12 @@
|
||||
@warning_ignore(unused_private_class_variable)
|
||||
@warning_ignore("unused_private_class_variable")
|
||||
var _unused = 2
|
||||
|
||||
@warning_ignore(unused_variable)
|
||||
@warning_ignore("unused_variable")
|
||||
func test():
|
||||
print("test")
|
||||
var unused = 3
|
||||
|
||||
@warning_ignore(redundant_await)
|
||||
@warning_ignore("redundant_await")
|
||||
print(await regular_func())
|
||||
|
||||
print("done")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# https://github.com/godotengine/godot/issues/50285
|
||||
|
||||
@warning_ignore(unused_local_constant)
|
||||
@warning_ignore("unused_local_constant")
|
||||
func test():
|
||||
const CONST_INNER_DICTIONARY = { "key": true }
|
||||
const CONST_NESTED_DICTIONARY_OLD_WORKAROUND = {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
@export var color: Color
|
||||
@export_color_no_alpha var color_no_alpha: Color
|
||||
@export_node_path(Sprite2D, Sprite3D, Control, Node) var nodepath := ^"hello"
|
||||
@export_node_path("Sprite2D", "Sprite3D", "Control", "Node") var nodepath := ^"hello"
|
||||
|
||||
|
||||
func test():
|
||||
|
||||
@@ -2,6 +2,6 @@ func wait() -> void:
|
||||
pass
|
||||
|
||||
func test():
|
||||
@warning_ignore(redundant_await)
|
||||
@warning_ignore("redundant_await")
|
||||
await wait()
|
||||
print("end")
|
||||
|
||||
@@ -7,11 +7,11 @@ func test():
|
||||
|
||||
func builtin_method():
|
||||
var pba := PackedByteArray()
|
||||
@warning_ignore(return_value_discarded)
|
||||
@warning_ignore("return_value_discarded")
|
||||
pba.resize(1) # Built-in validated.
|
||||
|
||||
|
||||
func builtin_method_static():
|
||||
var _pba := PackedByteArray()
|
||||
@warning_ignore(return_value_discarded)
|
||||
@warning_ignore("return_value_discarded")
|
||||
Vector2.from_angle(PI) # Static built-in validated.
|
||||
|
||||
@@ -11,10 +11,10 @@ class InnerClass:
|
||||
func _init() -> void:
|
||||
prints("Inner")
|
||||
'''
|
||||
@warning_ignore(return_value_discarded)
|
||||
@warning_ignore("return_value_discarded")
|
||||
gdscr.reload()
|
||||
|
||||
var inst = gdscr.new()
|
||||
|
||||
@warning_ignore(unsafe_method_access)
|
||||
@warning_ignore("unsafe_method_access")
|
||||
inst.test()
|
||||
|
||||
@@ -20,26 +20,26 @@ func test_utility(v, f):
|
||||
assert(not f) # Test unary operator reading from `nil`.
|
||||
|
||||
func test_builtin_call(v, f):
|
||||
@warning_ignore(unsafe_method_access)
|
||||
@warning_ignore("unsafe_method_access")
|
||||
v.angle() # Built-in method call.
|
||||
assert(not f) # Test unary operator reading from `nil`.
|
||||
|
||||
func test_builtin_call_validated(v: Vector2, f):
|
||||
@warning_ignore(return_value_discarded)
|
||||
@warning_ignore("return_value_discarded")
|
||||
v.abs() # Built-in method call validated.
|
||||
assert(not f) # Test unary operator reading from `nil`.
|
||||
|
||||
func test_object_call(v, f):
|
||||
@warning_ignore(unsafe_method_access)
|
||||
@warning_ignore("unsafe_method_access")
|
||||
v.get_reference_count() # Native type method call.
|
||||
assert(not f) # Test unary operator reading from `nil`.
|
||||
|
||||
func test_object_call_method_bind(v: Resource, f):
|
||||
@warning_ignore(return_value_discarded)
|
||||
@warning_ignore("return_value_discarded")
|
||||
v.duplicate() # Native type method call with MethodBind.
|
||||
assert(not f) # Test unary operator reading from `nil`.
|
||||
|
||||
func test_object_call_ptrcall(v: RefCounted, f):
|
||||
@warning_ignore(return_value_discarded)
|
||||
@warning_ignore("return_value_discarded")
|
||||
v.get_reference_count() # Native type method call with ptrcall.
|
||||
assert(not f) # Test unary operator reading from `nil`.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# https://github.com/godotengine/godot/issues/71172
|
||||
|
||||
func test():
|
||||
@warning_ignore(narrowing_conversion)
|
||||
@warning_ignore("narrowing_conversion")
|
||||
var foo: int = 0.0
|
||||
print(typeof(foo) == TYPE_INT)
|
||||
var dict : Dictionary = {"a":0.0}
|
||||
|
||||
Reference in New Issue
Block a user