Repository navigation
Releases
v1.0.2
Language & Diagnostics
- Boot-only
@intrinsic:@intrinsicannotations are now reserved for the built-in boot library. Using@intrinsicin user or mod scripts now produces a clearBOOT_ONLY_ANNOTATIONerror. - Fewer false array-safety warnings: Pure expressions before array literalsβsuch as arithmetic, comparison, logical, and unary operators, as well as side-effect-free nested array literalsβno longer trigger false
UNSAFE_ARRAY_EVALUATIONwarnings.
Type Checking
- Generic overload resolution: Fixed method overload matching when parameter types depend on a generic receiver's type arguments.
Code Generation & Bundle I/O
- Cleaner array initialization: Function-local arrays outside loops no longer emit redundant resets on entry, which also avoids false mutable-
letwarnings on emptyconstarrays in the decompiler. - Preserved operator metadata: Operator flags and names on free functions are now stored in and restored from compiled script bundles.
Performance & Parallelism
- Parallel compilation: The
redscript-cliandsccbinaries now parse scripts, lower function bodies, and run validation/diagnostics in parallel, while loading base game symbols concurrently with source parsing. - Opt-in parallel library builds: Library embedders can now enable thread-safe and parallel compilation via the
syncandparallelCargo features. - General speedups: Reduced memory allocations and lock contention during type lookup, name resolution, and REDmod wildcard import resolution.
REDmod Transpiler
- Cleaner generated names: Emits shorter unqualified names whenever imports make them unambiguous, including for enum values used in field defaults.
- Consistent capability checks: Single-function query mode now enforces
REDMOD_CAPABILITYerrors for unsafe array evaluations just like full compilation.
IDE & Query Support
- Targeted single-function analysis: Added query-mode analysis that type-checks and lowers only the function under the cursor while reusing base game symbols across queries for faster editor/LSP responsiveness.
SCC CLI & C API
- Safer C API error handling: Invalid UTF-8 type names are now logged and ignored instead of aborting the host process, out-of-bounds source reference lookups return
NULL, and error messages truncate cleanly on UTF-8 character boundaries. - CLI fixes: Fixed a small memory leak on early CLI errors and updated log timestamp formatting.
v1.0.1
Language & Diagnostics (const and script_ref<T>)
- Arbitrary fixed-size arrays: Fixed-size arrays (
[T; N]) now support arbitrary lengths (including nested arrays), removing the previous restriction to a predefined set of sizes. - Covariant
const script_ref<Struct>override returns: Method overrides can now returnconst script_ref<Struct>covariantly. construles in community scripts:thisinsideconstmethods andconstfields are now treated as read-only.- Method overrides are checked for
constcompatibility. ToVariantcalls and generic parameter types are checked for mutable forwarding ofconstvalues, and non-const method calls onconstparameters are rejected in strict mode.
- Diagnostic severity & message improvements:
- Writes to
constparameters,constreceivers (this), andconstfields are now reported as warnings (andconstoverride mismatches as runtime-allowed errors) to avoid breaking existing scripts while still surfacing issues. - Improved
constwrite diagnostic messages and removed duplicateconstoverride diagnostics onscript_refreturns.
- Writes to
script_ref<T>safety fixes:- Rejected escaping temporary
script_refvalues, non-nativescript_refreturns, andaspattern casts onscript_ref<T>. - Disallowed assigning read-only
script_ref/AsRefvalues to non-constscript_ref, as well as temporary-creating conversions into non-constscript_ref<T>lvalues. - Fixed
script_reftype validation on borrows in the REDmod transpiler.
- Rejected escaping temporary
Bug Fixes
- Omitted enum storage size: Enums without an explicit storage size now default to 4 bytes for
Int32-range values (and 8 bytes otherwise), matching 0.5.x and official REDmod behavior. - Module-scoped enum defaults: Enum default values now omit the module prefix (e.g.,
MyEnum.Valueinstead ofMyModule.MyEnum.Value). sccC API: Updated C API bindings to usec_charfor better cross-platform compatibility.
v1.0.0
REDscript 1.0 is a major rewrite of the compiler used by Cyberpunk 2077 script mods. It brings more reusable code, better error messages, faster compilation, and new tools for mod authorsβincluding editor support for native REDmod scripts and an optional REDmod export workflow.
At a glance
- Generics: write functions and types that work with different kinds of values.
- Lambdas: pass small functions as values, including functions that capture surrounding variables.
- Pattern matching: check and unpack arrays, objects, and references with less boilerplate.
- Smarter type inference: omit more local type annotations without giving up compile-time checks.
- Simpler class types: write
GameObjectinstead ofref<GameObject>where a strong reference is intended. - REDmod support: editor assistance and type checking for native scripts, plus export of supported community scripts.
- Better diagnostics and tools: clearer errors, configurable formatting, optional warnings, and decompiler improvements.
There are also compatibility changes. Mod authors upgrading from 0.5.x should read the migration section below.
New language features
Generics: reusable code without losing type information
A generic function works with more than one type. The type parameterβin this example, Tβstands for the type chosen at each call.
func Identity<T>(value: T) -> T {
return value;
}
func Demo() {
let number = Identity(42); // Int32
let text = Identity("hello"); // String
let explicit = Identity<Int32>(42);
}The compiler usually figures out T from the arguments. The return type still matches the input type: this does not turn the value into a Variant.
You can also define generic classes and structs:
struct Pair<A, B> {
let first: A;
let second: B;
}
func Demo() {
let pair = Pair(42, "hello");
// pair is a Pair<Int32, String>
}Restricting accepted types
Use extends when a function needs a particular base class:
class Animal {}
class Dog extends Animal {}
func Keep<T extends Animal>(value: T) -> T {
return value;
}
func Demo() {
let dog = Keep(new Dog());
// The result is still a Dog, not just an Animal.
}The compiler checks these restrictions both when the generic is defined and when it is used.
Advanced: variance
Generic classes can declare how their type arguments participate in inheritance:
+Tβ covariant: a producer ofDogcan be used where a producer ofAnimalis expected.-Tβ contravariant: something that accepts anyAnimalcan be used where something acceptingDogis expected.Tβ invariant: different type arguments are not interchangeable.
For example, a predicate only accepts values of its type:
abstract class Predicate<-T> {
public func Test(value: T) -> Bool;
}The compiler verifies that variance annotations are used safely. They are supported on class type parameters, not struct or function type parameters.
Lambdas: small functions you can pass around
A lambda is a function written directly inside an expression. You can store one in a variable or pass it to another function.
func Apply(value: Int32, transform: (Int32) -> Int32) -> Int32 {
return transform(value);
}
func Demo() {
let offset = 10;
let addOffset = (value: Int32) -> value + offset;
let result = Apply(5, addOffset); // 15
}Here, (Int32) -> Int32 means βa function that takes an Int32 and returns an Int32.β
A lambda can use variables from its surrounding scope. This is called capturing a variable; a function together with its captured values is called a closure.
For longer functions, use a block body and an explicit return:
func Demo() {
let doublePositive = (value: Int32) -> {
if value > 0 {
return value * 2;
}
return 0;
};
let result = doublePositive(5); // 10
}Parameter types can be omitted when the surrounding code provides enough information:
func Demo() {
let result = Apply(5, (value) -> value * 2);
}Captured locals are stored in the closure rather than becoming shared references to the original local variables. Capturing an object reference copies the referenceβnot the object itself.
Pattern matching: check and unpack a value together
Patterns describe the shape or type of a value and give names to the parts you need. They work in switch, if let, and while let.
Matching arrays
func LastOrZero(values: [Int32]) -> Int32 {
if let [.., last] = values {
return last;
}
return 0;
}The body runs only when the array has at least one element. Inside it, last contains the final element.
| Pattern | Matches |
|---|---|
[] |
An empty array |
[first, second] |
Exactly two elements |
[first, second, ..] |
At least two elements; names the first two |
[.., last] |
At least one element; names the last |
The .. ignores remaining elements. It belongs at one end of the pattern and does not create a separate array.
Matching does not remove elements. A while let repeats while the pattern matches; its body must change the relevant state if you want it to stop matching.
Checking an object's type and reading its fields
class Message {}
class DamageMessage extends Message {
public let amount: Int32;
}
func ReadDamage(message: Message) -> Int32 {
switch message {
case let DamageMessage { amount }:
return amount;
default:
return 0;
}
}This checks whether message is a DamageMessage and, if it is, binds its amount field.
You can also bind the object itself after a successful type check:
func ReadDamage(message: Message) -> Int32 {
if let damage as DamageMessage = message {
return damage.amount;
}
return 0;
}Checking for a defined reference
A ? pattern matches a non-null reference:
func HasMessage(message: Message) -> Bool {
if let present? = message {
return true;
}
return false;
}Patterns can nest, combining field extraction, reference checks, and array matching.
A
case letbranch must end explicitly withbreakorreturn. Falling through into a pattern branch is not allowed. Add a fallback branch when other values need handling.
Smarter type inference
The compiler can infer local types from how variables are usedβnot just from their initializers.
class Animal {}
class Dog extends Animal {}
class Cat extends Animal {}
func MakeAnimals() -> array<Animal> {
let animals;
ArrayPush(animals, new Dog());
ArrayPush(animals, new Cat());
return animals;
}The compiler uses the calls and return type to determine that animals is an array of Animal.
This is still static typing: the array's type is determined at compile time, not changed as the program runs.
Expected types also help with numeric literals and lambda parameters:
func Demo() {
let numbers: [Int64] = [1, 2, 3];
let callbacks: [(Int64) -> Int64] = [(value) -> value];
}You can keep explicit annotations wherever they make code clearer.
What has not changed: named function parameters still need types, and omitting a named function's return type still means Void.
Less ref<...> boilerplate
For class types, the compiler now supplies the strong-reference wrapper automatically:
class Message {}
func Echo(message: Message) -> Message {
return message;
}The parameter and return type above mean ref<Message>.
Explicit ref<Message> remains available. Other wrappers, such as wref<Message> and script_ref<...>, still have distinct meanings.
Generate a class factory with @deriveNew
Use @deriveNew() to generate a public static New method that allocates an instance and initializes its declared fields:
@deriveNew()
class Notification {
public let text: String;
public let priority: Int32;
}
func Demo() {
let notification = Notification.New("Quest updated", 1);
}Arguments follow the fields' declaration order. Inherited fields are not added to the generated parameter list.
This generates a factory method; it does not enable new Notification("Quest updated", 1).
More language improvements
continue in loops
Skip the rest of the current iteration and move to the next one:
func Demo() {
for value in [0, 1, 2, 3] {
if value == 0 {
continue;
}
// Work with nonzero values here.
}
}Constant locals and stronger const checks
Declare a local that must not be reassigned:
func Demo() {
const limit = 10;
// limit = 20; // Error
}Constant locals must be initialized in their declaration.
The compiler also checks more invalid mutations through const parameters, including direct field and array-element writes and mutating array operations.
These checks do not provide complete, deeply immutable object graphs: mutation through other aliases is not comprehensively tracked.
Automatic enum values and explicit storage types
Enum members can omit values, and enums can specify their underlying integer type:
public enum Stage: Uint8 {
Start = 1,
Middle,
End,
}Middle is 2 and End is 3. Values and automatic increments are checked against the chosen type's range.
Supported storage types are Int8, Uint8, Int16, Uint16, Int32, Uint32, and Int64.
Skip an optional argument without skipping later ones
An empty argument position means βomit this optional parameterβ:
``...
v0.5.32
What's Changed
- fix: support script bundles from game patch 2.5 by @alphanin9 in #202
New Contributors
- @alphanin9 made their first contribution in #202
Full Changelog: v0.5.31...v0.5.32
v1.0.0-preview.22
chore: Release redscript-ast version 1.0.0-preview.22
v1.0.0-preview.21
chore: Release redscript-ast version 1.0.0-preview.21
v1.0.0-preview.20
chore: Release redscript-ast version 1.0.0-preview.20
v1.0.0-preview.19
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...Pattern matching
Powerful pattern matching for switch and if let statements is now supported.
// matching based on a subtype
switch inst {
case let SubclassA { fieldA }:
return fieldA;
case let SubclassB { fieldB }:
return fieldB[0];
}// consuming an array
while let [.., last] = array {
ArrayPop(array);
}// safe downcasting
if let myClassInst as MyClass = inst {
}Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}Implicit ref
The compiler now inserts the ref type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
@deriveNew annotation
A new annotation was added for automatically generating a static method that can construct an instance of the annotated class.
@deriveNew()
class Pair {
let first: String;
let second: Int32;
}
func Func() {
let _ = Pair.New("a", 1);
}Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.
v0.5.31
[0.5.31] - 2025-08-28
Features
- Implements struct constructor syntax for forward compatibility
Contributors
- jekky
v1.0.0-preview.18
This is a preview compiler release. DO NOT USE IT UNLESS YOU'RE A DEVELOPER. For standard releases go here.
REDscript 1 is a rewrite of REDscript that introduces a lot of improvements and new very powerful features.
Major highlights
Generics
User-defined generics with constraints and variance annotations are now supported. The compiler verifies and enforces correctness of their variance and constraints.
func TakeObject<A extends GameObject>(obj: A) -> A ...// makes A contravariant
abstract class Predicate<-A> {
func Test(obj: A) -> Bool
}Lambdas
First-class anonymous functions that close over their environment are now supported.
func Demo(arg: Int32) {
let array = [1, 2, 3, 4, 5];
let result = FilterArray(array, (x) -> x % arg == 0);
}
func FilterArray<A>(arr: [A], filter: (A) -> Bool) -> [A] ...Pattern matching
Powerful pattern matching for switch and if let statements is now supported.
// matching based on a subtype
switch inst {
case let SubclassA { fieldA }:
return fieldA;
case let SubclassB { fieldB }:
return fieldB[0];
}// consuming an array
while let [.., last] = array {
ArrayPop(array);
}// safe downcasting
if let myClassInst as MyClass = inst {
}Hindley-Milner-based type inference
REDscript now uses a powerful type inference algorithm that enables type safety with few to no type annotations.
class Animal {}
class Pet extends Animal {}
class Human extends Animal {}
func Demo1() -> array<Animal> {
let array; // no type annotation needed
ArrayPush(array, new Pet()); // compiler infers that elements of `array` are at least Pet
ArrayPush(array, new Human()); // compiler adjusts array to the least upper type, Animal
return array;
}
func Demo2() {
let swap = (f, a, b) -> f(b, a);
swap((a, b) -> RandRange(0, 1) == 0 ? a : b, 1, 2);
}Implicit ref
The compiler now inserts the ref type automatically when needed.
class Class {}
// parameter and return type are `ref<Class>`
func Func(inst: Class) -> Class {...}New diagnostics
The compiler now supports some additional diagnostics.
abstract class Abstract<A> {
func Unimplemented() -> A;
}
class Concrete extends Abstract<Int32> {
}
[ERROR] scripts\Test.reds:50:7
class Concrete extends Abstract<Int32> {
^^^^^^^^^^
this class is missing some required method implementation(s):
func Unimplemented() -> Int32 {}
@deriveNew annotation
A new annotation was added for automatically generating a static method that can construct an instance of the annotated class.
@deriveNew()
class Pair {
let first: String;
let second: Int32;
}
func Func() {
let _ = Pair.New("a", 1);
}Improved parser with error recovery
The parser was rewritten with better diagnostics and error recovery in mind. The compiler now reports static analysis errors even when the syntax in the file is broken.
[ERROR] At scripts\Test.reds:50:3
let str: Int32 = "";
^
expected ';' after expression in statement
[ERROR] At scripts\Test.reds:50:20
let str: Int32 = "";
^^
type mismatch: found String when expected Int32
Improved I/O performance
The compiler reads and writes large binary files whenever it runs, which was one of the main bottlenecks in the past. The I/O code has been rewritten to avoid copying data and a typical full compiler run is now 2-5 times faster.