mt-lang 0.3.13 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/docs/index.html +31 -23
  4. data/docs/language-design.md +13 -17
  5. data/docs/language-manual.md +19 -7
  6. data/lib/milk_tea/base.rb +1 -1
  7. data/lib/milk_tea/core/ast.rb +2 -2
  8. data/lib/milk_tea/core/control_flow/builder.rb +62 -2
  9. data/lib/milk_tea/core/lowering/async/analysis.rb +3 -9
  10. data/lib/milk_tea/core/lowering/async/lowering.rb +2 -10
  11. data/lib/milk_tea/core/lowering/async/normalization.rb +2 -7
  12. data/lib/milk_tea/core/lowering/block.rb +1 -5
  13. data/lib/milk_tea/core/lowering/expressions.rb +47 -3
  14. data/lib/milk_tea/core/lowering/proc.rb +1 -5
  15. data/lib/milk_tea/core/lowering/resolve.rb +26 -2
  16. data/lib/milk_tea/core/lowering/scans.rb +3 -1
  17. data/lib/milk_tea/core/lowering/utils.rb +7 -28
  18. data/lib/milk_tea/core/parser/statements.rb +18 -12
  19. data/lib/milk_tea/core/pretty_printer/ast_formatter.rb +3 -11
  20. data/lib/milk_tea/core/semantic_analyzer/analysis_context.rb +2 -3
  21. data/lib/milk_tea/core/semantic_analyzer/flow_refinement.rb +1 -1
  22. data/lib/milk_tea/core/semantic_analyzer/function_binding.rb +1 -2
  23. data/lib/milk_tea/core/semantic_analyzer/nullability.rb +2 -4
  24. data/lib/milk_tea/core/semantic_analyzer/statements.rb +2 -8
  25. data/lib/milk_tea/core/semantic_analyzer/type_compatibility.rb +29 -2
  26. data/lib/milk_tea/core/types.rb +0 -6
  27. data/lib/milk_tea/tooling/linter/imports_platform.rb +2 -4
  28. data/lib/milk_tea/tooling/linter/release_rules.rb +1 -6
  29. data/lib/milk_tea/tooling/linter/source_helpers.rb +0 -6
  30. data/lib/milk_tea/tooling/linter/visitors.rb +4 -8
  31. data/lib/milk_tea/tooling/sexpr_dumper.rb +2 -0
  32. data/std/asset_pack.mt +1 -1
  33. data/std/async/libuv_runtime.mt +6 -6
  34. data/std/async/mailbox.mt +4 -4
  35. data/std/{cell.mt → box.mt} +9 -9
  36. data/std/cookie.mt +2 -2
  37. data/std/crypto.mt +1 -1
  38. data/std/curl/runtime.mt +10 -10
  39. data/std/fs.linux.mt +26 -26
  40. data/std/fs.windows.mt +22 -22
  41. data/std/goap.mt +2 -2
  42. data/std/http/server.mt +21 -21
  43. data/std/http.mt +14 -14
  44. data/std/jobs.mt +4 -4
  45. data/std/json.mt +5 -5
  46. data/std/log.mt +1 -1
  47. data/std/mem/tracking.mt +1 -1
  48. data/std/net/channel.mt +4 -4
  49. data/std/net/clock.mt +6 -6
  50. data/std/net/discovery.mt +7 -7
  51. data/std/net/lobby.mt +10 -10
  52. data/std/net/manager.mt +1 -1
  53. data/std/net/mux.mt +4 -4
  54. data/std/net/nat.mt +4 -4
  55. data/std/net/packet.mt +3 -3
  56. data/std/net/punch.mt +3 -3
  57. data/std/net/rpc.mt +3 -3
  58. data/std/net/session.mt +15 -15
  59. data/std/net/stun.mt +4 -4
  60. data/std/net/turn.mt +4 -4
  61. data/std/oauth2.mt +12 -12
  62. data/std/path.mt +8 -8
  63. data/std/process.mt +4 -4
  64. data/std/raylib/packed_assets.mt +5 -5
  65. data/std/serialize.mt +1 -1
  66. data/std/tar.mt +10 -10
  67. data/std/terminal.mt +18 -18
  68. data/std/tls.mt +8 -8
  69. data/std/uri.mt +1 -1
  70. data/std/utility.mt +1 -1
  71. metadata +3 -3
@@ -3,42 +3,42 @@ import std.mem.heap as heap
3
3
  ## Explicit single-value heap storage.
4
4
  ##
5
5
  ## This is the intended escape hatch for shared mutable proc state.
6
- ## Allocation stays visible at the call site via `cell.alloc(...)`.
7
- public struct Cell[T]:
6
+ ## Allocation stays visible at the call site via `box.alloc(...)`.
7
+ public struct Box[T]:
8
8
  storage: own[T]?
9
9
 
10
10
 
11
- public function alloc[T](value: T) -> Cell[T]:
11
+ public function alloc[T](value: T) -> Box[T]:
12
12
  let storage = heap.must_alloc[T](1)
13
13
  read(storage) = value
14
- return Cell[T](storage = storage)
14
+ return Box[T](storage = storage)
15
15
 
16
16
 
17
- extending Cell[T]:
17
+ extending Box[T]:
18
18
  public function as_ptr() -> ptr[T]:
19
19
  let storage = this.storage else:
20
- fatal(c"cell.Cell.as_ptr released cell")
20
+ fatal(c"box.Box.as_ptr released box")
21
21
 
22
22
  return storage
23
23
 
24
24
 
25
25
  public function get() -> T:
26
26
  let storage = this.storage else:
27
- fatal(c"cell.Cell.get released cell")
27
+ fatal(c"box.Box.get released box")
28
28
 
29
29
  return read(storage)
30
30
 
31
31
 
32
32
  public function set(value: T) -> void:
33
33
  let storage = this.storage else:
34
- fatal(c"cell.Cell.set released cell")
34
+ fatal(c"box.Box.set released box")
35
35
 
36
36
  read(storage) = value
37
37
 
38
38
 
39
39
  public function replace(value: T) -> T:
40
40
  let storage = this.storage else:
41
- fatal(c"cell.Cell.replace released cell")
41
+ fatal(c"box.Box.replace released box")
42
42
 
43
43
  let previous = read(storage)
44
44
  read(storage) = value
data/std/cookie.mt CHANGED
@@ -94,7 +94,7 @@ function apply_attribute(cookie: ref[Cookie], attribute_text: str) -> void:
94
94
  match eq:
95
95
  Option.none:
96
96
  var normalized = ascii_lower(attribute_text)
97
- defer normalized.release()
97
+ defer: normalized.release()
98
98
 
99
99
  if normalized.as_str().equal("secure"):
100
100
  cookie.secure = true
@@ -106,7 +106,7 @@ function apply_attribute(cookie: ref[Cookie], attribute_text: str) -> void:
106
106
  let value_text = attribute_text.slice(e.value + 1, attribute_text.len - e.value - 1).trim_ascii_whitespace()
107
107
 
108
108
  var normalized_key = ascii_lower(key_text)
109
- defer normalized_key.release()
109
+ defer: normalized_key.release()
110
110
 
111
111
  if normalized_key.as_str().equal("domain"):
112
112
  cookie.domain = Option[string.String].some(value = string.String.from_str(value_text))
data/std/crypto.mt CHANGED
@@ -23,7 +23,7 @@ public function sha256(data: span[ubyte]) -> bytes.Bytes:
23
23
 
24
24
  public function sha256_to_str(data: span[ubyte]) -> string.String:
25
25
  var digest = sha256(data)
26
- defer digest.release()
26
+ defer: digest.release()
27
27
 
28
28
  var result = string.String.with_capacity(raw.SHA256_DIGEST_LENGTH * 2)
29
29
  var index: ptr_uint = 0
data/std/curl/runtime.mt CHANGED
@@ -69,21 +69,21 @@ public function get_bytes(url: str) -> Result[bytes.Bytes, curl.Code]:
69
69
  return Result[bytes.Bytes, curl.Code].failure(error= curl.Code<-CURLE_URL_MALFORMAT_CODE)
70
70
 
71
71
  var scratch = arena.create(url.len + 1)
72
- defer scratch.release()
72
+ defer: scratch.release()
73
73
 
74
74
  let url_cstr = scratch.to_cstr(url)
75
75
 
76
76
  let global_status = curl.global_init(curl.CURL_GLOBAL_NOTHING)
77
77
  if int<-global_status != CURLE_OK_CODE:
78
78
  return Result[bytes.Bytes, curl.Code].failure(error= global_status)
79
- defer curl.global_cleanup()
79
+ defer: curl.global_cleanup()
80
80
 
81
81
  let handle = curl.easy_init() else:
82
82
  return Result[bytes.Bytes, curl.Code].failure(error= curl.Code<-CURLE_FAILED_INIT_CODE)
83
- defer curl.easy_cleanup(handle)
83
+ defer: curl.easy_cleanup(handle)
84
84
 
85
85
  var body = vec.Vec[ubyte].create()
86
- defer body.release()
86
+ defer: body.release()
87
87
 
88
88
  let write_function_status = easy_setopt_writefunction(handle, write_response_chunk)
89
89
  if int<-write_function_status != CURLE_OK_CODE:
@@ -199,7 +199,7 @@ function do_request(
199
199
  let global_status = curl.global_init(curl.CURL_GLOBAL_NOTHING)
200
200
  if int<-global_status != CURLE_OK_CODE:
201
201
  return Result[HttpResponse, HttpError].failure(error = http_error(global_status))
202
- defer curl.global_cleanup()
202
+ defer: curl.global_cleanup()
203
203
 
204
204
  let handle = curl.easy_init() else:
205
205
  return Result[HttpResponse, HttpError].failure(
@@ -208,10 +208,10 @@ function do_request(
208
208
  message = string.String.from_str("curl_easy_init failed")
209
209
  )
210
210
  )
211
- defer curl.easy_cleanup(handle)
211
+ defer: curl.easy_cleanup(handle)
212
212
 
213
213
  var buffer = vec.Vec[ubyte].create()
214
- defer buffer.release()
214
+ defer: buffer.release()
215
215
 
216
216
  let _wfn = easy_setopt_writefunction(handle, write_response_chunk)
217
217
  let _wdata = easy_setopt_writedata(handle, unsafe: ptr[void]<-ptr_of(buffer))
@@ -225,7 +225,7 @@ function do_request(
225
225
  )
226
226
 
227
227
  var scratch = arena.create(url.len + 1)
228
- defer scratch.release()
228
+ defer: scratch.release()
229
229
 
230
230
  let url_cstr = scratch.to_cstr(url)
231
231
  let _url = easy_setopt_url(handle, url_cstr)
@@ -237,12 +237,12 @@ function do_request(
237
237
  if body.is_some():
238
238
  let body_content = body.unwrap()
239
239
  var body_scratch = arena.create(body_content.len + 1)
240
- defer body_scratch.release()
240
+ defer: body_scratch.release()
241
241
  let _pf = easy_setopt_postfields(handle, body_scratch.to_cstr(body_content))
242
242
 
243
243
  if method.len > 0 and not method.starts_with("GET"):
244
244
  var method_scratch = arena.create(method.len + 1)
245
- defer method_scratch.release()
245
+ defer: method_scratch.release()
246
246
  let _method = easy_setopt_customrequest(handle, method_scratch.to_cstr(method))
247
247
 
248
248
  if method.starts_with("HEAD"):
data/std/fs.linux.mt CHANGED
@@ -89,7 +89,7 @@ function release_string_values(values: ref[vec.Vec[string.String]]) -> void:
89
89
 
90
90
  function path_kind(path: str) -> int:
91
91
  var storage = arena.create(path.len + 1)
92
- defer storage.release()
92
+ defer: storage.release()
93
93
  return c.mt_fs_path_kind(storage.to_cstr(path))
94
94
 
95
95
 
@@ -170,7 +170,7 @@ public function is_directory(path: str) -> bool:
170
170
 
171
171
  public function read_text(path: str) -> Result[string.String, Error]:
172
172
  var storage = arena.create(path.len + 1)
173
- defer storage.release()
173
+ defer: storage.release()
174
174
 
175
175
  var raw_text = zero[c.mt_fs_string]
176
176
  var raw_error = zero[c.mt_fs_error]
@@ -187,7 +187,7 @@ public function read_lines(path: str) -> Result[Entries, Error]:
187
187
  return Result[Entries, Error].failure(error= payload.error)
188
188
  Result.success as payload:
189
189
  var content = payload.value
190
- defer content.release()
190
+ defer: content.release()
191
191
 
192
192
  var values = vec.Vec[string.String].create()
193
193
  let content_text = content.as_str()
@@ -216,7 +216,7 @@ public function read_lines(path: str) -> Result[Entries, Error]:
216
216
 
217
217
  public function read_bytes(path: str) -> Result[bytes.Bytes, Error]:
218
218
  var storage = arena.create(path.len + 1)
219
- defer storage.release()
219
+ defer: storage.release()
220
220
 
221
221
  var raw_bytes = zero[c.mt_fs_string]
222
222
  var raw_error = zero[c.mt_fs_error]
@@ -229,7 +229,7 @@ public function read_bytes(path: str) -> Result[bytes.Bytes, Error]:
229
229
 
230
230
  public function metadata(path: str) -> Result[Metadata, Error]:
231
231
  var storage = arena.create(path.len + 1)
232
- defer storage.release()
232
+ defer: storage.release()
233
233
 
234
234
  var raw_metadata = zero[c.mt_fs_metadata]
235
235
  var raw_error = zero[c.mt_fs_error]
@@ -248,7 +248,7 @@ public function metadata(path: str) -> Result[Metadata, Error]:
248
248
 
249
249
  public function write_text(path: str, content: str) -> Result[bool, Error]:
250
250
  var storage = arena.create(path.len + 1)
251
- defer storage.release()
251
+ defer: storage.release()
252
252
 
253
253
  var raw_error = zero[c.mt_fs_error]
254
254
  let status_code = c.mt_fs_write_text(storage.to_cstr(path), content.data, content.len, raw_error)
@@ -260,7 +260,7 @@ public function write_text(path: str, content: str) -> Result[bool, Error]:
260
260
 
261
261
  public function write_bytes(path: str, content: span[ubyte]) -> Result[bool, Error]:
262
262
  var storage = arena.create(path.len + 1)
263
- defer storage.release()
263
+ defer: storage.release()
264
264
 
265
265
  var raw_error = zero[c.mt_fs_error]
266
266
  let status_code = c.mt_fs_write_bytes(storage.to_cstr(path), content.data, content.len, raw_error)
@@ -272,7 +272,7 @@ public function write_bytes(path: str, content: span[ubyte]) -> Result[bool, Err
272
272
 
273
273
  public function set_permissions(path: str, mode: int) -> Result[bool, Error]:
274
274
  var storage = arena.create(path.len + 1)
275
- defer storage.release()
275
+ defer: storage.release()
276
276
 
277
277
  var raw_error = zero[c.mt_fs_error]
278
278
  let status_code = c.mt_fs_set_permissions(storage.to_cstr(path), mode, raw_error)
@@ -284,7 +284,7 @@ public function set_permissions(path: str, mode: int) -> Result[bool, Error]:
284
284
 
285
285
  public function create_directories(path: str) -> Result[bool, Error]:
286
286
  var storage = arena.create(path.len + 1)
287
- defer storage.release()
287
+ defer: storage.release()
288
288
 
289
289
  var raw_error = zero[c.mt_fs_error]
290
290
  let status_code = c.mt_fs_create_directories(storage.to_cstr(path), raw_error)
@@ -307,7 +307,7 @@ public function copy_entry(source_path: str, target_path: str) -> Result[bool, E
307
307
  return Result[bool, Error].failure(error= payload.error)
308
308
  Result.success as payload:
309
309
  var data = payload.value
310
- defer data.release()
310
+ defer: data.release()
311
311
  return write_bytes(target_path, data.as_span())
312
312
 
313
313
  if is_directory(source_path):
@@ -322,7 +322,7 @@ public function copy_entry(source_path: str, target_path: str) -> Result[bool, E
322
322
  return Result[bool, Error].failure(error= payload.error)
323
323
  Result.success as payload:
324
324
  var entries = payload.value
325
- defer entries.release()
325
+ defer: entries.release()
326
326
 
327
327
  var index: ptr_uint = 0
328
328
  while index < entries.len():
@@ -334,9 +334,9 @@ public function copy_entry(source_path: str, target_path: str) -> Result[bool, E
334
334
  ].failure(error= static_error("fs copy entry missing source entry"))
335
335
  Option.some as entry_payload:
336
336
  var child_source = path_ops.join(source_path, entry_payload.value)
337
- defer child_source.release()
337
+ defer: child_source.release()
338
338
  var child_target = path_ops.join(target_path, entry_payload.value)
339
- defer child_target.release()
339
+ defer: child_target.release()
340
340
  match copy_entry(child_source.as_str(), child_target.as_str()):
341
341
  Result.failure as child_payload:
342
342
  return Result[bool, Error].failure(error= child_payload.error)
@@ -357,7 +357,7 @@ public function copy_entry(source_path: str, target_path: str) -> Result[bool, E
357
357
 
358
358
  public function remove(path: str) -> Result[bool, Error]:
359
359
  var storage = arena.create(path.len + 1)
360
- defer storage.release()
360
+ defer: storage.release()
361
361
 
362
362
  var raw_error = zero[c.mt_fs_error]
363
363
  let status_code = c.mt_fs_remove(storage.to_cstr(path), raw_error)
@@ -374,7 +374,7 @@ public function remove_tree(path: str) -> Result[bool, Error]:
374
374
  return Result[bool, Error].failure(error= payload.error)
375
375
  Result.success as payload:
376
376
  var entries = payload.value
377
- defer entries.release()
377
+ defer: entries.release()
378
378
 
379
379
  var index: ptr_uint = 0
380
380
  while index < entries.len():
@@ -383,7 +383,7 @@ public function remove_tree(path: str) -> Result[bool, Error]:
383
383
  return Result[bool, Error].failure(error= static_error("fs remove tree missing entry"))
384
384
  Option.some as entry_payload:
385
385
  var child_path = path_ops.join(path, entry_payload.value)
386
- defer child_path.release()
386
+ defer: child_path.release()
387
387
  match remove_tree(child_path.as_str()):
388
388
  Result.failure as child_payload:
389
389
  return Result[bool, Error].failure(error= child_payload.error)
@@ -401,9 +401,9 @@ public function remove_tree(path: str) -> Result[bool, Error]:
401
401
 
402
402
  public function rename(source_path: str, target_path: str) -> Result[bool, Error]:
403
403
  var source_storage = arena.create(source_path.len + 1)
404
- defer source_storage.release()
404
+ defer: source_storage.release()
405
405
  var target_storage = arena.create(target_path.len + 1)
406
- defer target_storage.release()
406
+ defer: target_storage.release()
407
407
 
408
408
  var raw_error = zero[c.mt_fs_error]
409
409
  let status_code = c.mt_fs_rename(
@@ -438,7 +438,7 @@ public function find_ancestor_containing(path: str, entry_name: str) -> Option[s
438
438
 
439
439
  while true:
440
440
  var candidate = path_ops.join(current.as_str(), entry_name)
441
- defer candidate.release()
441
+ defer: candidate.release()
442
442
  let found = exists(candidate.as_str())
443
443
  if found:
444
444
  return Option[string.String].some(value= current)
@@ -486,7 +486,7 @@ public function temporary_directory() -> string.String:
486
486
 
487
487
  public function canonicalize(path: str) -> Result[string.String, Error]:
488
488
  var storage = arena.create(path.len + 1)
489
- defer storage.release()
489
+ defer: storage.release()
490
490
 
491
491
  var raw_text = zero[c.mt_fs_string]
492
492
  var raw_error = zero[c.mt_fs_error]
@@ -505,7 +505,7 @@ public function create_temporary_directory(parent_dir: str, prefix: str) -> Resu
505
505
  ].failure(error= static_error("fs.create_temporary_directory requires a non-empty prefix"))
506
506
 
507
507
  var storage = arena.create(parent_dir.len + prefix.len + 2)
508
- defer storage.release()
508
+ defer: storage.release()
509
509
 
510
510
  var raw_text = zero[c.mt_fs_string]
511
511
  var raw_error = zero[c.mt_fs_error]
@@ -529,7 +529,7 @@ public function create_temporary_directory(parent_dir: str, prefix: str) -> Resu
529
529
 
530
530
  public function create_temporary_directory_in_system_temp(prefix: str) -> Result[string.String, Error]:
531
531
  var root = temporary_directory()
532
- defer root.release()
532
+ defer: root.release()
533
533
  return create_temporary_directory(root.as_str(), prefix)
534
534
 
535
535
 
@@ -541,7 +541,7 @@ public function create_temporary_file(parent_dir: str, prefix: str, suffix: str)
541
541
  ].failure(error= static_error("fs.create_temporary_file requires a non-empty prefix"))
542
542
 
543
543
  var storage = arena.create(parent_dir.len + prefix.len + suffix.len + 3)
544
- defer storage.release()
544
+ defer: storage.release()
545
545
 
546
546
  var raw_text = zero[c.mt_fs_string]
547
547
  var raw_error = zero[c.mt_fs_error]
@@ -563,13 +563,13 @@ public function create_temporary_file(parent_dir: str, prefix: str, suffix: str)
563
563
 
564
564
  public function create_temporary_file_in_system_temp(prefix: str, suffix: str) -> Result[string.String, Error]:
565
565
  var root = temporary_directory()
566
- defer root.release()
566
+ defer: root.release()
567
567
  return create_temporary_file(root.as_str(), prefix, suffix)
568
568
 
569
569
 
570
570
  public function list_entries(path: str) -> Result[Entries, Error]:
571
571
  var storage = arena.create(path.len + 1)
572
- defer storage.release()
572
+ defer: storage.release()
573
573
 
574
574
  var raw_entries = zero[c.mt_fs_entries]
575
575
  var raw_error = zero[c.mt_fs_error]
@@ -644,7 +644,7 @@ function collect_files_recursive(path: str, output: ref[vec.Vec[string.String]])
644
644
  return Result[bool, Error].failure(error= payload.error)
645
645
  Result.success as payload:
646
646
  var entries = payload.value
647
- defer entries.release()
647
+ defer: entries.release()
648
648
 
649
649
  var index: ptr_uint = 0
650
650
  while index < entries.len():
data/std/fs.windows.mt CHANGED
@@ -89,7 +89,7 @@ function release_string_values(values: ref[vec.Vec[string.String]]) -> void:
89
89
 
90
90
  function path_kind(path: str) -> int:
91
91
  var storage = arena.create(path.len + 1)
92
- defer storage.release()
92
+ defer: storage.release()
93
93
  return c.mt_fs_path_kind(storage.to_cstr(path))
94
94
 
95
95
 
@@ -170,7 +170,7 @@ public function is_directory(path: str) -> bool:
170
170
 
171
171
  public function read_text(path: str) -> Result[string.String, Error]:
172
172
  var storage = arena.create(path.len + 1)
173
- defer storage.release()
173
+ defer: storage.release()
174
174
 
175
175
  var raw_text = zero[c.mt_fs_string]
176
176
  var raw_error = zero[c.mt_fs_error]
@@ -187,7 +187,7 @@ public function read_lines(path: str) -> Result[Entries, Error]:
187
187
  return Result[Entries, Error].failure(error= payload.error)
188
188
  Result.success as payload:
189
189
  var content = payload.value
190
- defer content.release()
190
+ defer: content.release()
191
191
 
192
192
  var values = vec.Vec[string.String].create()
193
193
  let content_text = content.as_str()
@@ -216,7 +216,7 @@ public function read_lines(path: str) -> Result[Entries, Error]:
216
216
 
217
217
  public function read_bytes(path: str) -> Result[bytes.Bytes, Error]:
218
218
  var storage = arena.create(path.len + 1)
219
- defer storage.release()
219
+ defer: storage.release()
220
220
 
221
221
  var raw_bytes = zero[c.mt_fs_string]
222
222
  var raw_error = zero[c.mt_fs_error]
@@ -229,7 +229,7 @@ public function read_bytes(path: str) -> Result[bytes.Bytes, Error]:
229
229
 
230
230
  public function metadata(path: str) -> Result[Metadata, Error]:
231
231
  var storage = arena.create(path.len + 1)
232
- defer storage.release()
232
+ defer: storage.release()
233
233
 
234
234
  var raw_metadata = zero[c.mt_fs_metadata]
235
235
  var raw_error = zero[c.mt_fs_error]
@@ -248,7 +248,7 @@ public function metadata(path: str) -> Result[Metadata, Error]:
248
248
 
249
249
  public function write_text(path: str, content: str) -> Result[bool, Error]:
250
250
  var storage = arena.create(path.len + 1)
251
- defer storage.release()
251
+ defer: storage.release()
252
252
 
253
253
  var raw_error = zero[c.mt_fs_error]
254
254
  let status_code = c.mt_fs_write_text(storage.to_cstr(path), content.data, content.len, raw_error)
@@ -260,7 +260,7 @@ public function write_text(path: str, content: str) -> Result[bool, Error]:
260
260
 
261
261
  public function write_bytes(path: str, content: span[ubyte]) -> Result[bool, Error]:
262
262
  var storage = arena.create(path.len + 1)
263
- defer storage.release()
263
+ defer: storage.release()
264
264
 
265
265
  var raw_error = zero[c.mt_fs_error]
266
266
  let status_code = c.mt_fs_write_bytes(storage.to_cstr(path), content.data, content.len, raw_error)
@@ -272,7 +272,7 @@ public function write_bytes(path: str, content: span[ubyte]) -> Result[bool, Err
272
272
 
273
273
  public function set_permissions(path: str, mode: int) -> Result[bool, Error]:
274
274
  var storage = arena.create(path.len + 1)
275
- defer storage.release()
275
+ defer: storage.release()
276
276
 
277
277
  var raw_error = zero[c.mt_fs_error]
278
278
  let status_code = c.mt_fs_set_permissions(storage.to_cstr(path), mode, raw_error)
@@ -284,7 +284,7 @@ public function set_permissions(path: str, mode: int) -> Result[bool, Error]:
284
284
 
285
285
  public function create_directories(path: str) -> Result[bool, Error]:
286
286
  var storage = arena.create(path.len + 1)
287
- defer storage.release()
287
+ defer: storage.release()
288
288
 
289
289
  var raw_error = zero[c.mt_fs_error]
290
290
  let status_code = c.mt_fs_create_directories(storage.to_cstr(path), raw_error)
@@ -307,7 +307,7 @@ public function copy_entry(source_path: str, target_path: str) -> Result[bool, E
307
307
  return Result[bool, Error].failure(error= payload.error)
308
308
  Result.success as payload:
309
309
  var data = payload.value
310
- defer data.release()
310
+ defer: data.release()
311
311
  return write_bytes(target_path, data.as_span())
312
312
 
313
313
  if is_directory(source_path):
@@ -322,7 +322,7 @@ public function copy_entry(source_path: str, target_path: str) -> Result[bool, E
322
322
  return Result[bool, Error].failure(error= payload.error)
323
323
  Result.success as payload:
324
324
  var entries = payload.value
325
- defer entries.release()
325
+ defer: entries.release()
326
326
 
327
327
  var index: ptr_uint = 0
328
328
  while index < entries.len():
@@ -359,7 +359,7 @@ public function copy_entry(source_path: str, target_path: str) -> Result[bool, E
359
359
 
360
360
  public function remove(path: str) -> Result[bool, Error]:
361
361
  var storage = arena.create(path.len + 1)
362
- defer storage.release()
362
+ defer: storage.release()
363
363
 
364
364
  var raw_error = zero[c.mt_fs_error]
365
365
  let status_code = c.mt_fs_remove(storage.to_cstr(path), raw_error)
@@ -376,7 +376,7 @@ public function remove_tree(path: str) -> Result[bool, Error]:
376
376
  return Result[bool, Error].failure(error= payload.error)
377
377
  Result.success as payload:
378
378
  var entries = payload.value
379
- defer entries.release()
379
+ defer: entries.release()
380
380
 
381
381
  var index: ptr_uint = 0
382
382
  while index < entries.len():
@@ -404,9 +404,9 @@ public function remove_tree(path: str) -> Result[bool, Error]:
404
404
 
405
405
  public function rename(source_path: str, target_path: str) -> Result[bool, Error]:
406
406
  var source_storage = arena.create(source_path.len + 1)
407
- defer source_storage.release()
407
+ defer: source_storage.release()
408
408
  var target_storage = arena.create(target_path.len + 1)
409
- defer target_storage.release()
409
+ defer: target_storage.release()
410
410
 
411
411
  var raw_error = zero[c.mt_fs_error]
412
412
  let status_code = c.mt_fs_rename(
@@ -501,7 +501,7 @@ public function temporary_directory() -> string.String:
501
501
 
502
502
  public function canonicalize(path: str) -> Result[string.String, Error]:
503
503
  var storage = arena.create(path.len + 1)
504
- defer storage.release()
504
+ defer: storage.release()
505
505
 
506
506
  var raw_text = zero[c.mt_fs_string]
507
507
  var raw_error = zero[c.mt_fs_error]
@@ -520,7 +520,7 @@ public function create_temporary_directory(parent_dir: str, prefix: str) -> Resu
520
520
  ].failure(error= static_error("fs.create_temporary_directory requires a non-empty prefix"))
521
521
 
522
522
  var storage = arena.create(parent_dir.len + prefix.len + 2)
523
- defer storage.release()
523
+ defer: storage.release()
524
524
 
525
525
  var raw_text = zero[c.mt_fs_string]
526
526
  var raw_error = zero[c.mt_fs_error]
@@ -544,7 +544,7 @@ public function create_temporary_directory(parent_dir: str, prefix: str) -> Resu
544
544
 
545
545
  public function create_temporary_directory_in_system_temp(prefix: str) -> Result[string.String, Error]:
546
546
  var root = temporary_directory()
547
- defer root.release()
547
+ defer: root.release()
548
548
  return create_temporary_directory(root.as_str(), prefix)
549
549
 
550
550
 
@@ -556,7 +556,7 @@ public function create_temporary_file(parent_dir: str, prefix: str, suffix: str)
556
556
  ].failure(error= static_error("fs.create_temporary_file requires a non-empty prefix"))
557
557
 
558
558
  var storage = arena.create(parent_dir.len + prefix.len + suffix.len + 3)
559
- defer storage.release()
559
+ defer: storage.release()
560
560
 
561
561
  var raw_text = zero[c.mt_fs_string]
562
562
  var raw_error = zero[c.mt_fs_error]
@@ -578,13 +578,13 @@ public function create_temporary_file(parent_dir: str, prefix: str, suffix: str)
578
578
 
579
579
  public function create_temporary_file_in_system_temp(prefix: str, suffix: str) -> Result[string.String, Error]:
580
580
  var root = temporary_directory()
581
- defer root.release()
581
+ defer: root.release()
582
582
  return create_temporary_file(root.as_str(), prefix, suffix)
583
583
 
584
584
 
585
585
  public function list_entries(path: str) -> Result[Entries, Error]:
586
586
  var storage = arena.create(path.len + 1)
587
- defer storage.release()
587
+ defer: storage.release()
588
588
 
589
589
  var raw_entries = zero[c.mt_fs_entries]
590
590
  var raw_error = zero[c.mt_fs_error]
@@ -659,7 +659,7 @@ function collect_files_recursive(path: str, output: ref[vec.Vec[string.String]])
659
659
  return Result[bool, Error].failure(error= payload.error)
660
660
  Result.success as payload:
661
661
  var entries = payload.value
662
- defer entries.release()
662
+ defer: entries.release()
663
663
 
664
664
  var index: ptr_uint = 0
665
665
  while index < entries.len():
data/std/goap.mt CHANGED
@@ -233,9 +233,9 @@ extending Planner[World, Goal, Context]:
233
233
 
234
234
  public editable function plan(context: ref[Context], initial_world: World, goal: Goal) -> PlanningResult[World]:
235
235
  var nodes = vec.Vec[SearchNode[World]].create()
236
- defer nodes.release()
236
+ defer: nodes.release()
237
237
  var open_list = vec.Vec[ptr_uint].create()
238
- defer open_list.release()
238
+ defer: open_list.release()
239
239
 
240
240
  nodes.push(
241
241
  SearchNode[World](