Commit remaining unstaged changes

This commit is contained in:
2026-04-04 15:47:15 +02:00
parent fb0c2078cd
commit 46ba82bc55
8 changed files with 76 additions and 25 deletions

View File

@@ -11,7 +11,7 @@ binDir = "bin"
# Dependencies
requires "nim >= 2.2.6", "nimcrypto >= 0.6.2", "noise >= 0.1.6"
requires "nim == 2.2.6", "nimcrypto >= 0.6.2", "noise >= 0.1.6"
task test, "Runs the test suite":

View File

@@ -6,17 +6,6 @@
# - bounded queue back-pressure (push blocks when full)
# - fan-in: many producers, one consumer
import sync/queues;
import sync/events;
import builtins/async_runtime;
import builtins/values;
import builtins/seq;
import builtins/arithmetics;
import builtins/comparisons;
import builtins/logical;
import strings;
# --- 1. FIFO ordering ---
async fn testFIFOOrder() {

Binary file not shown.

View File

@@ -36,7 +36,7 @@ fn concat(a, b: string): string {
}
type deque*[T] = object {
type deque*[T] = object with Printable {
buffer: Buffer[T];
head: int64;
length: int64;

View File

@@ -14,6 +14,7 @@ import arrays;
import ranges;
import strings;
import sync/events;
import sync/queues;
import net;
@@ -33,4 +34,5 @@ export arrays;
export ranges;
export strings;
export events;
export queues;
export net;

View File

@@ -490,6 +490,68 @@ fn test(): int64 {
check sawFlat
check sawNested
test "recursive nested generic fields preserve self-specialized bindings":
let mono = monomorphizeSource("""
type Option[T] = enum {
Some {
value: T;
},
None
}
fn none[T](_: typevar[T]): Option[T] {
return None();
}
type Node[T] = ref object {
value: T;
prev: Option[Node[T]];
next: Option[Node[T]];
}
fn leaf(): Node[int64] {
return Node[int64](value = 1, prev = none(Node[int64]), next = none(Node[int64]));
}
""")
var specialized: TypedTypeDecl = nil
for node in mono:
if node.node.kind != NodeKind.typeDecl:
continue
let decl = TypedTypeDecl(node)
if decl.name.ident.token.lexeme.startsWith("Node__"):
specialized = decl
break
check not specialized.isNil()
let nodeType = specialized.name.valueType.unwrapType()
let payload =
if nodeType.kind == Reference:
nodeType.value.unwrapType()
else:
nodeType
check payload.kind == Structure
let prevType = payload.fields["prev"].unwrapType()
check prevType.kind == Structure
var somePayload: Type = nil
for variant in prevType.variants:
if "value" in variant.fields:
somePayload = variant.fields["value"].unwrapType()
break
check not somePayload.isNil()
let recursivePayload =
if somePayload.kind == Reference:
somePayload.value.unwrapType()
else:
somePayload
check recursivePayload.kind == Structure
check "value" in recursivePayload.fields
check "prev" in recursivePayload.fields
check "next" in recursivePayload.fields
test "specialized function bodies rewrite lent parameter types under indexed projections":
let checked = typecheckSource("""
type Box = object {

View File

@@ -669,8 +669,7 @@ value.len();
test "plain assignment operator declarations still parse":
let tree = parseSource("""
operator `=`*(a: mut lent int64, b: int64): int64 {
return b;
operator `=`*(a: mut lent int64, b: int64) {
}
""")

View File

@@ -27,8 +27,8 @@ operator `[]`*[N: const int64, T](self: mut lent array[N, T], index: int64): mut
#pragma[magic: "ArrayIndex", lentFrom: self]
}
operator `[]=`*[N: const int64, T](self: mut lent array[N, T], index: int64, value: T): mut lent T {
#pragma[magic: "ArrayIndexAssign", lentFrom: self]
operator `[]=`*[N: const int64, T](self: mut lent array[N, T], index: int64, value: T) {
#pragma[magic: "ArrayIndexAssign"]
}
"""
@@ -41,12 +41,12 @@ operator `[]`*[T](self: mut lent ptr UncheckedArray[T], index: int64): mut lent
#pragma[magic: "PointerIndex", lentFrom: self]
}
operator `[]=`*[T](self: ptr UncheckedArray[T], index: int64, value: T): mut lent T {
#pragma[magic: "PointerIndexAssign", lentFrom: self]
operator `[]=`*[T](self: ptr UncheckedArray[T], index: int64, value: T) {
#pragma[magic: "PointerIndexAssign"]
}
operator `[]=`*[T](self: mut lent ptr UncheckedArray[T], index: int64, value: T): mut lent T {
#pragma[magic: "PointerIndexAssign", lentFrom: self]
operator `[]=`*[T](self: mut lent ptr UncheckedArray[T], index: int64, value: T) {
#pragma[magic: "PointerIndexAssign"]
}
"""
@@ -1126,8 +1126,7 @@ type int64 = object {
#pragma[magic: "int64"]
}
operator `=`*(a: mut lent int64, b: int64): int64 {
return b;
operator `=`*(a: mut lent int64, b: int64) {
}
""", "cannot overload '='")
@@ -6548,8 +6547,8 @@ operator `[]`(value: mut lent Vec, index: int64): int64 {
return index;
}
operator `[]=`(value: mut lent Vec, index: int64, newValue: int64): int64 {
return newValue;
operator `[]=`(value: mut lent Vec, index: int64, newValue: int64) {
let ignored = newValue;
}
fn test(): int64 {