chore: import upstream snapshot with attribution
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped

This commit is contained in:
wehub-resource-sync
2026-07-13 12:29:30 +08:00
commit e7738de6d2
1723 changed files with 216139 additions and 0 deletions
@@ -0,0 +1,7 @@
fn helper(value: i32) -> i32 {
return value + 1
}
export c fn main() -> i32 {
return 42
}
@@ -0,0 +1,20 @@
pub fn main(world: World) -> Void raises {
var backing: [8]u8 = [0, 0, 0, 0, 0, 0, 0, 0]
var alloc: FixedBufAlloc = std.mem.fixedBufAlloc(backing)
let first: Maybe<MutSpan<u8>> = std.mem.allocBytes(alloc, 3)
let second: Maybe<MutSpan<u8>> = std.mem.allocBytes(alloc, 5)
let overflow: Maybe<MutSpan<u8>> = std.mem.allocBytes(alloc, 1)
let nullAlloc: NullAlloc = std.mem.nullAlloc()
let nullBytes: Maybe<MutSpan<u8>> = std.mem.allocBytes(nullAlloc, 1)
if first.has && second.has && !overflow.has && !nullBytes.has && std.mem.len(first.value) == 3 && std.mem.len(second.value) == 5 {
first.value[0] = 65
second.value[4] = 90
if backing[0] == 65 && backing[7] == 90 {
check world.out.write("allocator primitives ok\n")
} else {
check world.out.write("allocator primitives wrote wrong bytes\n")
}
} else {
check world.out.write("allocator primitives failed\n")
}
}
Binary file not shown.
@@ -0,0 +1,9 @@
export c fn main() -> i32 {
let bytes: [8]u8 = [7_u8; 8]
var scratch: [16]u8 = [0_u8; 16]
scratch[8] = bytes[0]
if bytes[7] == 7_u8 && scratch[0] == 0_u8 && scratch[8] == 7_u8 && std.mem.len(scratch) == 16 {
return 0
}
return 1
}
Binary file not shown.
@@ -0,0 +1,11 @@
type Bytes4 {
bytes: [4]u8,
}
export c fn main() -> i32 {
let value: Bytes4 = Bytes4 { bytes: [7_u8; 4] }
if value.bytes[0] == 7_u8 && value.bytes[3] == 7_u8 {
return 0
}
return 1
}
@@ -0,0 +1,17 @@
type Holder {
value: ref<i32>,
count: i32,
}
fn replaceValue(holder: mutref<Holder>, next: ref<i32>) -> i32 {
holder.value = next
return 1
}
pub fn main() -> Void {
var old: i32 = 1
let next: i32 = 2
var holder: Holder = Holder { value: &old, count: 0 }
holder.count = replaceValue(&mut holder, &next)
old = 3
}
+8
View File
@@ -0,0 +1,8 @@
pub fn main(world: World) -> Void raises {
var flags: [5]Bool = [false; 5]
flags[1] = true
flags[3] = true
if !flags[0] && flags[1] && (flags[3] && !flags[4]) {
check world.out.write("bool arrays ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,10 @@
type Box {
value: mutref<i32>,
}
pub fn main() -> Void {
var x: i32 = 1
var box: Box = Box { value: &mut x }
box.value = &mut x
box = Box { value: &mut x }
}
@@ -0,0 +1,8 @@
pub fn main() -> Void {
var x: i32 = 1
var y: i32 = 2
var r: mutref<i32> = &mut y
r = &mut y
r = &mut x
y = 3
}
@@ -0,0 +1,11 @@
pub fn main(flag: Bool) -> Void {
var x: i32 = 1
let y: i32 = 2
var r: ref<i32> = &x
if flag {
r = &y
} else {
r = &y
}
x = 3
}
@@ -0,0 +1,14 @@
type Pair {
left: i32,
right: i32,
}
pub fn main() -> Void {
var pair: Pair = Pair { left: 1, right: 2 }
let left: ref<i32> = &pair.left
pair.right = 3
var second: Pair = Pair { left: 4, right: 5 }
let second_left: mutref<i32> = &mut second.left
second.right = 6
let second_right: mutref<i32> = &mut second.right
}
@@ -0,0 +1,35 @@
type Point {
x: i32,
y: i32,
}
type Holder {
point: Point,
}
fn read_x(point: ref<Point>) -> i32 {
return point.x
}
fn write_x(point: mutref<Point>, value: i32) -> Void {
point.x = value
}
pub fn main(world: World) -> Void raises {
var point: Point = Point { x: 1, y: 2 }
var holder: Holder = Holder { point: Point { x: 3, y: 4 } }
if true {
let shared: ref<Point> = &point
if read_x(shared) != 1 {
check world.out.write("borrow primitives failed\n")
return
}
}
write_x(&mut point, 5)
write_x(&mut holder.point, 9)
if point.x == 5 && holder.point.x == 9 {
check world.out.write("borrow primitives ok\n")
} else {
check world.out.write("borrow primitives failed\n")
}
}
Binary file not shown.
@@ -0,0 +1,22 @@
type Box {
value: ref<i32>,
}
fn get(box: ref<Box>) -> ref<i32> {
return box.value
}
fn getMut(box: mutref<Box>) -> ref<i32> {
return box.value
}
pub fn main() -> Void {
var x: i32 = 1
let y: i32 = 2
let z: i32 = 3
var box: Box = Box { value: &x }
let current: ref<i32> = get(&box)
box.value = &y
let other: ref<i32> = getMut(&mut box)
box.value = &z
}
@@ -0,0 +1,14 @@
type Point {
x: i32,
y: i32,
}
fn field(point: ref<Point>) -> ref<i32> {
return &point.x
}
pub fn main() -> Void {
var point: Point = Point { x: 1, y: 2 }
let current: ref<i32> = field(&point)
point.y = 3
}
@@ -0,0 +1,8 @@
fn keep(r: ref<i32>) -> ref<i32> {
return r
}
pub fn main() -> Void {
let x: i32 = 1
let r: ref<i32> = keep(&x)
}
@@ -0,0 +1,14 @@
type Point {
x: i32,
y: i32,
}
fn field(point: ref<Point>) -> ref<i32> {
let pointRef: ref<Point> = point
return &pointRef.x
}
pub fn main() -> Void {
let point: Point = Point { x: 1, y: 2 }
let current: ref<i32> = field(&point)
}
@@ -0,0 +1,10 @@
pub fn main() -> Void {
var x: i32 = 1
let z: i32 = 2
var r: ref<i32> = &x
if true {
let x: i32 = 3
r = &z
}
x = 4
}
@@ -0,0 +1,15 @@
fn choose(left: ref<i32>, right: ref<i32>) -> ref<i32> {
if true {
return left
} else {
return left
}
return right
}
pub fn main() -> Void {
let x: i32 = 1
var y: i32 = 2
let current: ref<i32> = choose(&x, &y)
y = 3
}
@@ -0,0 +1,13 @@
fn choose(left: ref<i32>, right: ref<i32>) -> ref<i32> {
while false {
return right
}
return left
}
pub fn main() -> Void {
let x: i32 = 1
var y: i32 = 2
let current: ref<i32> = choose(&x, &y)
y = 3
}
@@ -0,0 +1,23 @@
enum Mode {
left,
alsoLeft,
}
fn choose(mode: Mode, left: ref<i32>, right: ref<i32>) -> ref<i32> {
match mode {
left {
return left
}
alsoLeft {
return left
}
}
return right
}
pub fn main(mode: Mode) -> Void {
let x: i32 = 1
var y: i32 = 2
let current: ref<i32> = choose(mode, &x, &y)
y = 3
}
@@ -0,0 +1,11 @@
fn choose(left: ref<i32>, right: ref<i32>) -> ref<i32> raises [Done] {
raise Done
return right
}
pub fn main() -> Void raises [Done] {
let x: i32 = 1
var y: i32 = 2
let current: ref<i32> = check choose(&x, &y)
y = 3
}
@@ -0,0 +1,14 @@
fn choose(left: ref<i32>, right: ref<i32>) -> ref<i32> {
if true {
return left
} else {
return right
}
}
pub fn main() -> Void {
let x: i32 = 1
var y: i32 = 2
let current: ref<i32> = choose(&x, &y)
y = 3
}
@@ -0,0 +1,15 @@
type Holder {
value: ref<i32>,
}
pub fn main(flag: Bool) -> Void {
var old: i32 = 1
let next: i32 = 2
var holder: Holder = Holder { value: &old }
if flag {
holder.value = &next
} else {
holder.value = &next
}
old = 3
}
+13
View File
@@ -0,0 +1,13 @@
pub fn main(world: World) -> Void raises {
var index: i32 = 0
while index < 5 {
index = index + 1
if index == 2 {
continue
}
if index == 4 {
break
}
check world.out.write("loop tick\n")
}
}
Binary file not shown.
@@ -0,0 +1,34 @@
fn bump(bytes: MutSpan<u8>) -> String {
bytes[0] = bytes[0] + 1_u8
return bytes[..1]
}
fn firstByte(text: String) -> u8 {
return text[0]
}
pub fn main(world: World) -> Void raises {
var storage: [1]u8 = [96]
var ok: Bool = true
if !std.mem.eql(bump(storage), "a") {
ok = false
}
if storage[0] != 97_u8 {
ok = false
}
if firstByte(bump(storage)) != 98_u8 {
ok = false
}
if storage[0] != 98_u8 {
ok = false
}
if !std.mem.eql(bump(storage), "c") {
ok = false
}
if storage[0] != 99_u8 {
ok = false
}
if ok {
check world.out.write("byte view call single eval ok\n")
}
}
@@ -0,0 +1,22 @@
fn byteSum(bytes: Span<u8>) -> u32 {
var total: u32 = 0
var i: usize = 0
while i < std.mem.len(bytes) {
total = total + bytes[i] as u32
i = i + 1
}
return total
}
fn second(bytes: Span<u8>) -> u8 {
return bytes[1]
}
pub fn main(world: World) -> Void raises {
let text: Span<u8> = std.mem.span("agent")
let data: [5]u8 = [10, 20, 30, 40, 50]
let window: Span<u8> = data[1..4]
if byteSum(std.mem.span("hi")) == 209 && byteSum(text) == 527 && second(text) == 103 as u8 && byteSum(window) == 90 && second(window) == 30_u8 {
check world.out.write("byte view params ok\n")
}
}
Binary file not shown.
+15
View File
@@ -0,0 +1,15 @@
extern type CPoint {
x: i32,
y: i32,
}
export c fn zero_add(a: i32, b: i32) -> i32 {
return a + b
}
pub fn main(world: World) -> Void raises {
let point: CPoint = CPoint { x: 2, y: 3 }
if zero_add(point.x, point.y) == 5 {
check world.out.write("c abi export ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,7 @@
extern c "conformance/c/simple.h" as c
export c fn main() -> i32 {
let total: i32 = c.zero_c_add(20, 22)
let c: i32 = 1
return total + c
}
@@ -0,0 +1,16 @@
extern c "conformance/c/simple.h" as Counter
type Counter {
value: i32,
fn zero_c_add(self: ref<Self>, a: i32, b: i32) -> i32 {
return self.value + a + b
}
}
export c fn main() -> i32 {
let counter: Counter = Counter { value: 1000 }
if Counter.zero_c_add(&counter, 20, 22) == 1042 {
return 0
}
return 1
}
+23
View File
@@ -0,0 +1,23 @@
type CharBag {
letter: char,
newline: char,
quote: char,
slash: char,
hex: char,
}
fn echoChar(value: char) -> char {
return value
}
pub fn main(world: World) -> Void raises {
let letter: char = 'A'
let newline: char = '\n'
let quote: char = '\''
let slash: char = '\\'
let hex: char = 'A'
let bag: CharBag = CharBag { letter: letter, newline: newline, quote: quote, slash: slash, hex: hex }
if letter == hex && echoChar(bag.letter) == 'A' && bag.newline == newline && bag.quote == quote && bag.slash == slash {
check world.out.write("char literals ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,13 @@
fn first_or_none(bytes: Span<u8>, index: usize) -> Maybe<u8> raises {
check std.mem.get(bytes, index)
return std.mem.get(bytes, index)
}
pub fn main(world: World) -> Void raises {
let bytes: [2]u8 = [8, 9]
let hit: Maybe<u8> = first_or_none(bytes, 1)
let miss: Maybe<u8> = first_or_none(bytes, 9)
if hit.has && hit.value == 9_u8 && !miss.has {
check world.out.write("check maybe fallibility ok\n")
}
}
@@ -0,0 +1,10 @@
pub fn main(world: World) -> Void raises {
let bytes: [3]u8 = [4, 5, 6]
let text: String = "zero"
let first: Maybe<u8> = std.mem.get(bytes, 1)
let missing: Maybe<u8> = std.mem.get(bytes, 9)
let letter: Maybe<u8> = std.mem.get(text, 0)
if first.has && first.value == 5_u8 && !missing.has && letter.has && letter.value == 122 as u8 {
check world.out.write("checked bounds get ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,17 @@
type S {
value: i32,
fn risky(self: ref<Self>) -> Void raises [Bad] {
raise Bad
}
}
interface Risky<T: Type> {
fn risky(self: ref<T>) -> Void raises [Bad]
}
fn run<T: Risky<T>>(value: ref<T>) -> Void raises [Bad] {
check T.risky(value)
}
pub fn main() -> Void {
}
@@ -0,0 +1,10 @@
type S {
value: i32,
fn risky() -> Void raises [Bad] {
raise Bad
}
}
pub fn main() -> Void raises [Bad] {
check S.risky()
}
@@ -0,0 +1,14 @@
fn inner(flag: Bool) -> Void raises [Bad] {
if flag {
raise Bad
}
}
fn wrapper() -> Void raises {
check inner(false)
}
pub fn main(world: World) -> Void raises {
check wrapper()
check world.out.write("checked fallible wrapper ok\n")
}
@@ -0,0 +1,16 @@
choice Slot {
some: ref<i32>,
none,
}
pub fn main() -> Void {
let value: i32 = 1
let slot: Slot = Slot.some(&value)
match slot {
.some(borrowed) {
let _same: ref<i32> = borrowed
}
none {
}
}
}
@@ -0,0 +1,21 @@
choice Slot {
some: ref<i32>,
none,
}
fn get(slot: Slot, fallback: ref<i32>) -> ref<i32> {
match slot {
.some(borrowed) {
return borrowed
}
none {
return fallback
}
}
}
pub fn main() -> Void {
let value: i32 = 1
let slot: Slot = Slot.some(&value)
let _borrowed: ref<i32> = get(slot, &value)
}
@@ -0,0 +1,14 @@
choice Slot {
some: ref<i32>,
none,
}
fn pass(slot: Slot) -> Slot {
return slot
}
pub fn main() -> Void {
let value: i32 = 1
let slot: Slot = Slot.some(&value)
let _copy: Slot = pass(slot)
}
@@ -0,0 +1,9 @@
pub fn main(world: World) -> Void raises {
let text: String = "abcdef"
let start: usize = 1
let end: usize = 4
let middle: Span<u8> = text[start..end]
if std.mem.len(middle) == 3 {
check world.out.write("dynamic slice ok\n")
}
}
@@ -0,0 +1,14 @@
export c fn main() -> u8 {
var storage: [8]u8 = [0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8, 0_u8]
var alloc: FixedBufAlloc = std.mem.fixedBufAlloc(storage)
let first: Maybe<MutSpan<u8>> = std.mem.allocBytes(alloc, 4)
if first.has {
if std.mem.len(first.value) == 4 {
let bytes: MutSpan<u8> = first.value
if std.mem.len(bytes) == 4 {
return first.value[0]
}
}
}
return 0_u8
}
+48
View File
@@ -0,0 +1,48 @@
const enabled: Bool = meta(target.pointerWidth >= 32 && hasField(Point, "x"))
const selected: Mode = Mode.fast
const field_count: usize = meta fieldCount(Point)
const field_type: String = meta fieldType(Point, "x")
const mode_cases: usize = meta enumCaseCount(Mode)
const has_tiny: Bool = meta hasEnumCase(Mode, "tiny")
const event_cases: usize = meta choiceCaseCount(Event)
const has_tick: Bool = meta hasChoiceCase(Event, "tick")
type Point {
x: i32,
y: i32,
}
type Gate<static enabledFlag: Bool, static selectedMode: Mode> {
value: i32,
}
enum Mode: u8 {
fast,
tiny,
}
choice Event {
none,
tick: i32,
}
fn readGate<static enabledFlag: Bool, static selectedMode: Mode>(gate: ref<Gate<enabledFlag, selectedMode>>) -> i32 {
if enabledFlag {
return gate.value
}
return 0
}
pub fn main(world: World) -> Void raises {
let gate: Gate<enabled, selected> = Gate { value: 29 }
if readGate<enabled, selected>(&gate) == 29 && field_count == 2 && mode_cases == 2 && event_cases == 2 && has_tiny && has_tick && std.mem.eql(field_type, "i32") {
check world.out.write("compile time v1 ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,11 @@
const base: i32 = 40
const answer: i32 = base + 2
pub fn main(world: World) -> Void raises {
if answer == 42 {
check world.out.write("const arithmetic ok\n")
} else {
check world.out.write("const arithmetic broke\n")
}
}
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
extern type CPoint {
x: i32,
y: i32,
}
packed type Header {
tag: u8,
len: u16,
}
type Wrapper {
value: const i32,
}
pub fn main(world: World) -> Void raises {
let point: CPoint = CPoint { x: 1, y: 2 }
let header: Header = Header { tag: 7_u8, len: 9_u16 }
let wrapper: Wrapper = Wrapper { value: 11 }
if point.x == 1 && header.len == 9_u16 && wrapper.value == 11 {
check world.out.write("const layout ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,26 @@
type FixedVec<T: Type, static N: usize> {
len: usize = 0,
items: [N]T,
fn init(items: [N]T) -> Self {
return FixedVec { items: items }
}
fn push(self: mutref<Self>, value: T) -> Void raises [Full] {
if self.len == N {
raise Full
}
self.items[self.len] = value
self.len = self.len + 1
}
fn get(self: ref<Self>, index: usize) -> Maybe<T> {
return std.mem.get(self.items, index)
}
}
pub fn main(world: World) -> Void raises {
var vec: FixedVec<u8, 4> = FixedVec.init<u8, 4>([0, 0, 0, 0])
check vec.push(42)
let first: Maybe<u8> = vec.get(0)
if first.has && first.value == 42 {
check world.out.write("constructors defaults ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,27 @@
fn mark(marker: MutSpan<u8>, value: u8) -> Void {
marker[0] = value
}
fn early(marker: MutSpan<u8>) -> Void {
defer mark(marker, 1)
return
}
fn fail(marker: MutSpan<u8>) -> i32 raises [Boom] {
defer mark(marker, 2)
raise Boom
}
pub fn main(world: World) -> Void raises {
var early_marker: [1]u8 = [0]
var raise_marker: [1]u8 = [0]
var nested_marker: [1]u8 = [0]
early(early_marker)
let recovered: i32 = rescue fail(raise_marker) err 7
if true {
defer mark(nested_marker, 3)
}
if early_marker[0] == 1 && raise_marker[0] == 2 && nested_marker[0] == 3 && recovered == 7 {
check world.out.write("defer return raise nested ok\n")
}
}
@@ -0,0 +1,48 @@
export c fn main() -> i32 {
let crc_text: u32 = std.codec.crc32("zero")
let crc_bytes: u32 = std.codec.crc32Bytes(std.mem.span("zero hash payload\n"))
let hash: u32 = std.crypto.hash32(std.mem.span("message"))
var fixed_buf: [8]u8 = [0_u8; 8]
var hash_buf: [8]u8 = [0_u8; 8]
var hmac_buf: [8]u8 = [0_u8; 8]
var id_buf: [8]u8 = [0_u8; 8]
var sha_buf: [64]u8 = [0_u8; 64]
var hmac_sha_buf: [64]u8 = [0_u8; 64]
let fixed: Maybe<Span<u8>> = std.crypto.fixedHex32(fixed_buf, 48879_u32)
let hash_hex: Maybe<Span<u8>> = std.crypto.hashHex32(hash_buf, std.mem.span("message"))
let hmac_hex: Maybe<Span<u8>> = std.crypto.hmacHex32(hmac_buf, std.mem.span("key"), std.mem.span("message"))
let stable_id: Maybe<Span<u8>> = std.crypto.stableId32(id_buf, std.mem.span("message"))
let sha: Maybe<Span<u8>> = std.crypto.sha256Hex(sha_buf, std.mem.span("abc"))
let hmac_sha: Maybe<Span<u8>> = std.crypto.hmacSha256Hex(hmac_sha_buf, std.mem.span("key"), std.mem.span("The quick brown fox jumps over the lazy dog"))
if crc_text != 2883514770_u32 || crc_bytes != 1120241454_u32 || hash != 3065852031_u32 {
return 1
}
if !fixed.has || !hash_hex.has || !hmac_hex.has || !stable_id.has {
return 1
}
if !sha.has {
return 1
}
if !hmac_sha.has {
return 1
}
if !std.mem.eql(fixed.value, "0000beef") {
return 1
}
if !std.mem.eql(hash_hex.value, "b6bd307f") {
return 1
}
if !std.mem.eql(hmac_hex.value, "0000000a") {
return 1
}
if !std.mem.eql(stable_id.value, "b6bd307f") {
return 1
}
if !std.mem.eql(sha.value, "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad") {
return 1
}
if !std.mem.eql(hmac_sha.value, "f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8") {
return 1
}
return 0
}
@@ -0,0 +1,15 @@
fn dynamicIndex() -> usize {
return 1
}
pub fn main(world: World) -> Void raises {
var bytes: [2]u8 = [0_u8, 0_u8]
var words: [2]u16 = [0_u16, 0_u16]
bytes[dynamicIndex() % 2_usize] = 90_u8
words[dynamicIndex() % 2_usize] = 4660_u16
if bytes[1] == 90_u8 && words[1] == 4660_u16 {
check world.out.write("dynamic indexed store ok\n")
} else {
check world.out.write("dynamic indexed store failed\n")
}
}
@@ -0,0 +1,9 @@
pub fn main(world: World) -> Void raises {
let big: u32 = 300
let byte: u8 = big as u8
let word: u16 = 70000 as u16
let wide: u64 = byte as u64
if byte == 44_u8 && word == 4464_u16 && wide == 44_u64 {
check world.out.write("explicit cast narrow direct ok\n")
}
}
+32
View File
@@ -0,0 +1,32 @@
type CastBag {
byte: u8,
count: u32,
size: usize,
signed: isize,
}
fn narrow(value: u32) -> u8 {
return value as u8
}
fn widen(value: u8) -> u32 {
return value as u32
}
fn toSize(value: i32) -> usize {
return value as usize
}
pub fn main(world: World) -> Void raises {
let big: u32 = 300
let small: u8 = 42
let byte: u8 = big as u8
let count: u32 = small as u32
let size: usize = count as usize
let offset: isize = small as isize
let sum: u16 = small as u16 + 1 as u16
let bag: CastBag = CastBag { byte: big as u8, count: small as u32, size: count as usize, signed: small as isize }
if byte == 44 && count == 42 && size == 42 && offset == 42 && sum == 43 && narrow(big) == 44 && widen(small) == 42 && toSize(7) == 7 && bag.byte == 44 {
check world.out.write("explicit casts ok\n")
}
}
Binary file not shown.
@@ -0,0 +1,15 @@
fn value() -> i32 raises [BadInput] {
return 42
}
fn run() -> i32 raises [BadInput] {
let result: i32 = check value()
return result
}
pub fn main(world: World) -> Void raises {
let result: i32 = check run()
if result == 42 {
check world.out.write("check value ok\n")
}
}
@@ -0,0 +1,26 @@
type DropProbe {
marker: MutSpan<u8>,
fn drop(self: mutref<Self>) -> Void {
self.marker[0] = 1
}
}
fn maybe_fail(should_fail: Bool, marker: MutSpan<u8>) -> i32 raises [BadInput] {
let probe: owned<DropProbe> = DropProbe { marker: marker }
if should_fail {
raise BadInput
}
return 42
}
fn run(marker: MutSpan<u8>) -> Void raises [BadInput] {
check maybe_fail(false, marker)
}
pub fn main(world: World) -> Void raises {
var marker: [1]u8 = [0]
check run(marker)
if marker[0] == 1_u8 {
check world.out.write("fallibility error sets ok\n")
}
}
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More