From 1d2e55f53dfab5153dbfd0c03f28cd9daedb3b77 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 6 Apr 2025 19:20:07 -0400 Subject: Allow uninitialized variables when there's a sensible empty value (defaults to empty/zero value) --- test/arrays.tm | 6 +++++- test/defer.tm | 2 +- test/import.tm | 4 ++-- test/iterators.tm | 2 +- test/reductions.tm | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/arrays.tm b/test/arrays.tm index f2ed2c7a..8122106c 100644 --- a/test/arrays.tm +++ b/test/arrays.tm @@ -3,6 +3,10 @@ func main() >> nums : [Num32] = [] = [] + do + >> nums : [Num32] + = [] + do >> arr := [10, 20, 30] = [10, 20, 30] @@ -104,7 +108,7 @@ func main() >> heap := @[(i * 1337) mod 37 for i in 10] >> heap.heapify() >> heap - heap_order : @[Int] = @[] + heap_order : @[Int] repeat heap_order.insert(heap.heap_pop() or stop) >> heap_order[] == heap_order.sorted() diff --git a/test/defer.tm b/test/defer.tm index e5033075..6c204851 100644 --- a/test/defer.tm +++ b/test/defer.tm @@ -1,6 +1,6 @@ func main() x := 123 - nums : @[Int] = @[] + nums : @[Int] do defer nums.insert(x) diff --git a/test/import.tm b/test/import.tm index a6a6fa16..0686190b 100644 --- a/test/import.tm +++ b/test/import.tm @@ -8,11 +8,11 @@ func returns_imported_type(->ImportedType) return get_value() # Imported from ./use_import.tm func main() - >> empty : [vectors.Vec2] = [] + >> empty : [vectors.Vec2] >> returns_vec() = Vec2(x=1, y=2) - >> imported : [ImportedType] = [] + >> imported : [ImportedType] >> returns_imported_type() = ImportedType("Hello") diff --git a/test/iterators.tm b/test/iterators.tm index 1816fd7a..08382cff 100644 --- a/test/iterators.tm +++ b/test/iterators.tm @@ -25,7 +25,7 @@ func main() = ["AB", "BC", "CD"] do - result : @[Text] = @[] + result : @[Text] for foo in pairwise(values) result.insert("$(foo.x)$(foo.y)") >> result[] diff --git a/test/reductions.tm b/test/reductions.tm index 2666e1a9..3ec2ef5e 100644 --- a/test/reductions.tm +++ b/test/reductions.tm @@ -4,7 +4,7 @@ func main() >> (+: [10, 20, 30]) = 60? - >> empty_ints : [Int] = [] + >> empty_ints : [Int] >> (+: empty_ints) = none -- cgit v1.2.3