GDScript Subset Reference
GDCC supports mixed typed and weakly typed GDScript. Properties, locals, parameters, and return values may use explicit types, or may omit them and use Variant. Variant is the dynamic value boundary. Use explicit types when you want earlier assignment, call-argument, and return checks.
var typed_score: int = 10var dynamic_payload
func mix(value, count: int) -> Variant: var local := count + 1 dynamic_payload = value return localSupported declared type families:
| Group | Types |
|---|---|
| dynamic / empty / no return | Variant, Nil, null, void, Void |
| scalar | bool, int, float |
| string-like | String, StringName, NodePath |
| math and geometry | Vector2, Vector2i, Vector3, Vector3i, Vector4, Vector4i, Rect2, Rect2i, Transform2D, Transform3D, Plane, Quaternion, AABB, Basis, Projection, Color |
| handle and callable | RID, Callable, Signal |
| containers | Array, Dictionary, packed arrays |
| objects | Object, engine classes, GDCC script classes, visible inner classes |
Supported typed containers:
var nodes: Array[Node]var workers: Array[Worker]var payloads: Dictionary[StringName, Node]Supported type boundaries:
- same type to same type.
- any stable type to
Variant. - stable
Variantto a concrete target type. - object subclass to object superclass.
nullto object types.- limited
Array/Dictionarycovariance.
Unsupported common conversions:
int -> float.float -> int.String -> StringName.StringName -> String.- integer vectors to float vectors.
- enum as a first-class typed boundary.
Classes
Section titled “Classes”Supported:
class_name Playerextends Node
class Worker extends RefCounted: var value: intclass_name Name.class_name Name extends Base.- standalone top-level
extends Base. - omitted
class_name, with a class name derived from the file name. - omitted
extends, defaulting toRefCounted. - inner classes with
class Name:andclass Name extends Base:. - nested inner classes.
Unsupported:
extends "res://base.gd".- autoload superclass binding.
- cross-module superclass binding.
- complex superclass expressions.
Annotations
Section titled “Annotations”Supported:
@export var visible_payload: Variant@onready var target: Node@exporton class properties.@onreadyon non-static class properties whose owner class inheritsNode.
Unsupported or not meaningful for compiled scripts:
@export_range(...).- function
@rpc(...)behavior. @warning_ignore(...)behavior.- runtime behavior of
@tooland@icon.
Members
Section titled “Members”Supported properties:
var score: int = 0var payload: Variantvar values: Array[int]var worker: Worker = Worker.new()Supported signals:
signal changed(value: int)signal ready()Supported functions:
func add(a: int, b: int) -> int: return a + b
static func build() -> Worker: return Worker.new()
func _init() -> void: passUnsupported or limited:
- script
static var. - class or local
const. - property
:=as non-Variantmetadata. - parameter defaults.
- parameterized GDCC custom class
.new(...). - using
selfinsidestatic func.
Supported engine virtual overrides:
func _ready() -> void: pass
func _process(delta: float) -> void: pass
func _physics_process(delta: float) -> void: passVirtual overrides must match parameter count, parameter types, return type, and instance/static shape.
Statements
Section titled “Statements”Supported:
pass.- comments.
- local
var. - assignment.
- compound assignment.
returnandreturn expr.if/elif/else.while.- loop-local
breakandcontinue.
func sum(limit: int) -> int: var index := 0 var total := 0 while index < limit: if index == 3: index += 1 continue total += index index += 1 return totalSupported compound assignment operators:
+=,-=,*=,/=,%=,**=.<<=,>>=,&=,^=,|=.
Unsupported:
for.match.assert.await.- lambda bodies.
- coroutine flow.
Expressions
Section titled “Expressions”Supported literals:
- integers.
- floats.
true/false.null.- strings, including common escapes and UTF-8 text.
StringNameliterals such as&"Player".
Supported expression forms:
- identifiers.
self.- property chains.
- subscript reads and writes.
- bare calls.
- method calls.
- static calls.
- utility calls.
- constructors.
- unary and binary operators.
- parenthesized expressions.
Supported constructors:
var vector: Vector3 = Vector3(1.0, 2.0, 3.0)var values: Array = Array()var table: Dictionary = Dictionary()var node: Node = Node.new()var worker: Worker = Worker.new()Supported unary operators:
not,!, unary+, unary-,~.
Supported binary operators:
| Group | Operators |
|---|---|
| logical short-circuit | and, &&, or, ` |
| arithmetic | +, -, *, /, %, ** |
| bitwise | <<, >>, &, |, ^ |
| comparison | ==, !=, <, <=, >, >= |
| containment | in |
Unsupported expressions:
| Syntax | Alternative |
|---|---|
[1, 2, 3] | Array() + push_back |
{"a": 1} | Dictionary() + assignment |
a if cond else b | if statements |
preload(...) | avoid |
$Node | avoid shorthand |
value as Type | constructors or typed boundaries |
value is Type | avoid |
| lambda | normal function |
await expr | avoid |
Containers
Section titled “Containers”Array style:
var values: Array = Array()values.push_back(1)values.push_back(2)Dictionary style:
var scores: Dictionary = Dictionary()scores["alpha"] = 2scores["beta"] = 5Packed array style:
var values: PackedInt32Array = PackedInt32Array()values.push_back(4)values.push_back(5)return values[0] + values[1]Complete Example
Section titled “Complete Example”class_name InventoryCounterextends Node
class Item extends RefCounted: var amount: int
func set_amount(next: int) -> void: amount = next
func read_amount() -> int: return amount
var total: int = 0
func make_item(amount: int) -> Item: var item: Item = Item.new() item.set_amount(amount) return item
func add_amounts(values: Array) -> int: var index := 0 total = 0 while index < values.size(): var item: Item = make_item(int(values[index])) total += item.read_amount() index += 1 return totalUnsupported Quick Reference
Section titled “Unsupported Quick Reference”| Syntax | Status |
|---|---|
for item in values: | unsupported |
match value: | unsupported |
func f(a = 1): | unsupported parameter default |
assert(condition) | unsupported |
await signal | unsupported |
| lambda | unsupported |
const X = 1 | unsupported |
static var x: int | unsupported |
[1, 2, 3] | unsupported |
{"a": 1} | unsupported |
a if cond else b | unsupported |
preload(...) | unsupported |
$Node | unsupported |
value as Type | unsupported |
value is Type | unsupported |
not in | unsupported |
extends "res://base.gd" | unsupported |
Custom.new(arg) | unsupported for GDCC custom classes |