Renderingen-US

mutabilitas

Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.

MU-1 baseline: shallow const list mutation stays legal.

Syntax: const list<int> xs

Category#

type

Examples#

radix/corpus/mutabilitas/shallow-const.fab (canonical · concept)#

MU-1 baseline: shallow const list mutation stays legal.

# =============================================================================
# mutabilitas — unmarked shallow const (D-1)
# =============================================================================

main {
    const list<int> xs  []
    xs.append(4)
    print xs.length()
}

Expected output:

1

radix/corpus/mutabilitas/grammar-reject.fab (supporting · reject)#

GSD-9 reject harness: use after own transfer is rejected.

# =============================================================================
# mutabilitas — grammar reject harness (MU-3)
# =============================================================================
# This exemplum intentionally fails to compile. The sibling .expected file
# pins only the stable diagnostic identity, not paths or rendered prose.

main {
    const own list<int> xs  [1]
    const own list<int> ys  xs
    print xs.length()
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/mut-alias-conflict.fab (supporting · reject)#

MU-4 red: two mut locals from one source conflict (SEM052).

# =============================================================================
# mutabilitas — overlapping mut locals (MU-4)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    var list<int> a  [1, 2, 3]
    var mut list<int> b  a
    var mut list<int> c  a
    print b.length()
    print c.length()
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/mut-overlap-args.fab (supporting · reject)#

MU-4 red: the same value passed to two mut parameters conflicts.

# =============================================================================
# mutabilitas — overlapping mut arguments (MU-4)
# =============================================================================
# This exemplum intentionally fails to compile.

fn swap(mut list<int> a, mut list<int> b)  void {
    a.append(1)
    b.append(2)
}

main {
    var list<int> xs  [1, 2, 3]
    swap(xs, xs)
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/mut-shared-conflict.fab (supporting · reject)#

MU-4 red: mut local after a live ref local of the same source is SEM052.

# =============================================================================
# mutabilitas — mut vs live ref (MU-4)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    var list<int> a  [1, 2, 3]
    const ref list<int> r  a
    var mut list<int> b  a
    print r.length()
    print b.length()
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/mut-use-while-borrowed.fab (supporting · reject)#

MU-4 red: use of a source while a mut local borrows it is SEM052.

# =============================================================================
# mutabilitas — use while mutably borrowed (MU-4)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    var list<int> a  [1, 2, 3]
    var mut list<int> b  a
    print a.length()
    print b.length()
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/mut-write-while-borrowed.fab (supporting · reject)#

MU-4 red: write of a source while a mut local borrows it is SEM052.

# =============================================================================
# mutabilitas — write while borrowed (MU-4)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    var list<int> a  [1, 2, 3]
    var mut list<int> b  a
    a.append(4)
    print b.length()
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/own-from-field.fab (supporting · reject)#

MU-3 red: field projection into own rejects with copy suggestion.

# =============================================================================
# mutabilitas — field into own bind (MU-3)
# =============================================================================
# This exemplum intentionally fails to compile.

class Person {
    list<int> friends
}

main {
    const Person p  Person { friends = [1, 2] }
    const own list<int> b  p.friends
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/own-from-index.fab (supporting · reject)#

MU-3 red: index projection into own rejects with copy suggestion.

# =============================================================================
# mutabilitas — index into own bind (MU-3)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    const list<list<int>> xs  [[1], [2]]
    const own list<int> b  xs[0]
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/own-from-mut.fab (supporting · reject)#

MU-3 red: mut source into own rejects with copy suggestion.

# =============================================================================
# mutabilitas — mut into own bind (MU-3)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    var mut list<int> a  [1, 2, 3]
    const own list<int> b  a
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/own-from-ref.fab (supporting · reject)#

MU-3 red: ref source into own rejects with copy suggestion.

# =============================================================================
# mutabilitas — ref into own bind (MU-3)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    const ref list<int> a  [1, 2, 3]
    const own list<int> b  a
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/own-from-shared.fab (supporting · reject)#

MU-3 red: branched shared RHS into own rejects with copy suggestion.

# =============================================================================
# mutabilitas — shared branch into own bind (MU-3)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    const list<int> a  [1]
    const list<int> b  [2]
    const own list<int> c  true ? a : b
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/own-from-unmarked.fab (supporting · reject)#

MU-3 red: live unmarked source into own rejects with copy suggestion.

# =============================================================================
# mutabilitas — unmarked live into own (MU-3)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    const list<int> a  [1, 2, 3]
    const own list<int> b  a
    print a.length()
    print b.length()
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/own-use-after-move.fab (supporting · reject)#

MU-3 red: use of an own source after bind-site transfer is SEM050.

# =============================================================================
# mutabilitas — own use after move (MU-3)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    const own list<int> a  [1, 2, 3]
    const own list<int> b  a
    print a.length()
    print b.length()
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/ref-assign-projection.fab (supporting · reject)#

MU-2 red: projection assignment through a ref root is rejected.

# =============================================================================
# mutabilitas — ref projection assignment (MU-2)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    const ref list<int> xs  [1, 2, 3]
    xs[0]  9
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/ref-genus-field.fab (supporting · reject)#

MU-2 red: mutating a referential field of a ref genus is rejected.

# =============================================================================
# mutabilitas — ref genus field transitivity (MU-2)
# =============================================================================
# This exemplum intentionally fails to compile.

class Person {
    list<int> friends
}

main {
    const ref Person p  Person { friends = [1, 2] }
    p.friends.append(3)
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/ref-mutating-receiver.fab (supporting · reject)#

MU-2 red: mutating receiver intrinsic through a ref root is rejected.

# =============================================================================
# mutabilitas — ref mutating receiver (MU-2)
# =============================================================================
# This exemplum intentionally fails to compile.

main {
    const ref list<int> xs  [1, 2, 3]
    xs.append(4)
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/ref-to-mut.fab (supporting · reject)#

MU-2 red: passing a ref value into a mut position is rejected.

# =============================================================================
# mutabilitas — ref into mut (MU-2)
# =============================================================================
# This exemplum intentionally fails to compile.

fn poke(mut list<int> xs)  void {
    xs.append(4)
}

main {
    const ref list<int> a  [1, 2, 3]
    poke(a)
}

Expected: compilation rejects this example.

radix/corpus/mutabilitas/ref-to-own.fab (supporting · reject)#

MU-2 red: passing a ref value into an own position is rejected.

# =============================================================================
# mutabilitas — ref into own (MU-2)
# =============================================================================
# This exemplum intentionally fails to compile.

fn take(own list<int> xs)  void {
    print xs.length()
}

main {
    const ref list<int> a  [1, 2, 3]
    take(a)
}

Expected: compilation rejects this example.