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
data/std/terminal.mt CHANGED
@@ -695,7 +695,7 @@ public function flush_stderr() -> Result[bool, Error]:
695
695
 
696
696
  public function clear_screen() -> Result[bool, Error]:
697
697
  var sequence = string.String.with_capacity(8)
698
- defer sequence.release()
698
+ defer: sequence.release()
699
699
  append_csi(ref_of(sequence), "2J")
700
700
  append_csi(ref_of(sequence), "H")
701
701
  return write_stdout_sequence(sequence, "terminal clear screen failed")
@@ -703,21 +703,21 @@ public function clear_screen() -> Result[bool, Error]:
703
703
 
704
704
  public function clear_line() -> Result[bool, Error]:
705
705
  var sequence = string.String.with_capacity(5)
706
- defer sequence.release()
706
+ defer: sequence.release()
707
707
  append_csi(ref_of(sequence), "2K")
708
708
  return write_stdout_sequence(sequence, "terminal clear line failed")
709
709
 
710
710
 
711
711
  public function cursor_home() -> Result[bool, Error]:
712
712
  var sequence = string.String.with_capacity(4)
713
- defer sequence.release()
713
+ defer: sequence.release()
714
714
  append_csi(ref_of(sequence), "H")
715
715
  return write_stdout_sequence(sequence, "terminal cursor home failed")
716
716
 
717
717
 
718
718
  public function move_cursor(row: int, column: int) -> Result[bool, Error]:
719
719
  var sequence = string.String.with_capacity(24)
720
- defer sequence.release()
720
+ defer: sequence.release()
721
721
  append_escape(ref_of(sequence))
722
722
  sequence.append_format(f"[#{clamp_cursor_position_1based(row)};#{clamp_cursor_position_1based(column)}H")
723
723
  return write_stdout_sequence(sequence, "terminal move cursor failed")
@@ -725,35 +725,35 @@ public function move_cursor(row: int, column: int) -> Result[bool, Error]:
725
725
 
726
726
  public function hide_cursor() -> Result[bool, Error]:
727
727
  var sequence = string.String.with_capacity(8)
728
- defer sequence.release()
728
+ defer: sequence.release()
729
729
  append_csi(ref_of(sequence), "?25l")
730
730
  return write_stdout_sequence(sequence, "terminal hide cursor failed")
731
731
 
732
732
 
733
733
  public function show_cursor() -> Result[bool, Error]:
734
734
  var sequence = string.String.with_capacity(8)
735
- defer sequence.release()
735
+ defer: sequence.release()
736
736
  append_csi(ref_of(sequence), "?25h")
737
737
  return write_stdout_sequence(sequence, "terminal show cursor failed")
738
738
 
739
739
 
740
740
  public function enter_alternate_screen() -> Result[bool, Error]:
741
741
  var sequence = string.String.with_capacity(10)
742
- defer sequence.release()
742
+ defer: sequence.release()
743
743
  append_csi(ref_of(sequence), "?1049h")
744
744
  return write_stdout_sequence(sequence, "terminal alternate screen failed")
745
745
 
746
746
 
747
747
  public function leave_alternate_screen() -> Result[bool, Error]:
748
748
  var sequence = string.String.with_capacity(10)
749
- defer sequence.release()
749
+ defer: sequence.release()
750
750
  append_csi(ref_of(sequence), "?1049l")
751
751
  return write_stdout_sequence(sequence, "terminal alternate screen failed")
752
752
 
753
753
 
754
754
  public function enable_mouse() -> Result[bool, Error]:
755
755
  var sequence = string.String.with_capacity(24)
756
- defer sequence.release()
756
+ defer: sequence.release()
757
757
  append_csi(ref_of(sequence), "?1000h")
758
758
  append_csi(ref_of(sequence), "?1002h")
759
759
  append_csi(ref_of(sequence), "?1006h")
@@ -762,7 +762,7 @@ public function enable_mouse() -> Result[bool, Error]:
762
762
 
763
763
  public function disable_mouse() -> Result[bool, Error]:
764
764
  var sequence = string.String.with_capacity(24)
765
- defer sequence.release()
765
+ defer: sequence.release()
766
766
  append_csi(ref_of(sequence), "?1006l")
767
767
  append_csi(ref_of(sequence), "?1002l")
768
768
  append_csi(ref_of(sequence), "?1000l")
@@ -771,7 +771,7 @@ public function disable_mouse() -> Result[bool, Error]:
771
771
 
772
772
  public function set_foreground(color: Color) -> Result[bool, Error]:
773
773
  var sequence = string.String.with_capacity(10)
774
- defer sequence.release()
774
+ defer: sequence.release()
775
775
  append_escape(ref_of(sequence))
776
776
  sequence.append("[")
777
777
  append_color_code(ref_of(sequence), color, false)
@@ -781,7 +781,7 @@ public function set_foreground(color: Color) -> Result[bool, Error]:
781
781
 
782
782
  public function set_background(color: Color) -> Result[bool, Error]:
783
783
  var sequence = string.String.with_capacity(10)
784
- defer sequence.release()
784
+ defer: sequence.release()
785
785
  append_escape(ref_of(sequence))
786
786
  sequence.append("[")
787
787
  append_color_code(ref_of(sequence), color, true)
@@ -791,7 +791,7 @@ public function set_background(color: Color) -> Result[bool, Error]:
791
791
 
792
792
  public function set_rgb_foreground(red: int, green: int, blue: int) -> Result[bool, Error]:
793
793
  var sequence = string.String.with_capacity(24)
794
- defer sequence.release()
794
+ defer: sequence.release()
795
795
  append_escape(ref_of(sequence))
796
796
  sequence.append_format(
797
797
  f"[38;2;#{clamp_color_channel(red)};#{clamp_color_channel(green)};#{clamp_color_channel(blue)}m"
@@ -801,7 +801,7 @@ public function set_rgb_foreground(red: int, green: int, blue: int) -> Result[bo
801
801
 
802
802
  public function set_rgb_background(red: int, green: int, blue: int) -> Result[bool, Error]:
803
803
  var sequence = string.String.with_capacity(24)
804
- defer sequence.release()
804
+ defer: sequence.release()
805
805
  append_escape(ref_of(sequence))
806
806
  sequence.append_format(
807
807
  f"[48;2;#{clamp_color_channel(red)};#{clamp_color_channel(green)};#{clamp_color_channel(blue)}m"
@@ -811,7 +811,7 @@ public function set_rgb_background(red: int, green: int, blue: int) -> Result[bo
811
811
 
812
812
  public function set_bold(enabled: bool) -> Result[bool, Error]:
813
813
  var sequence = string.String.with_capacity(6)
814
- defer sequence.release()
814
+ defer: sequence.release()
815
815
  if enabled:
816
816
  append_csi(ref_of(sequence), "1m")
817
817
  else:
@@ -821,7 +821,7 @@ public function set_bold(enabled: bool) -> Result[bool, Error]:
821
821
 
822
822
  public function set_underline(enabled: bool) -> Result[bool, Error]:
823
823
  var sequence = string.String.with_capacity(6)
824
- defer sequence.release()
824
+ defer: sequence.release()
825
825
  if enabled:
826
826
  append_csi(ref_of(sequence), "4m")
827
827
  else:
@@ -831,7 +831,7 @@ public function set_underline(enabled: bool) -> Result[bool, Error]:
831
831
 
832
832
  public function reset_style() -> Result[bool, Error]:
833
833
  var sequence = string.String.with_capacity(5)
834
- defer sequence.release()
834
+ defer: sequence.release()
835
835
  append_csi(ref_of(sequence), "0m")
836
836
  return write_stdout_sequence(sequence, "terminal style reset failed")
837
837
 
@@ -958,7 +958,7 @@ extending Terminal:
958
958
  return Result[Option[Event], Error].success(value= Option[Event].some(value= ev.unwrap()))
959
959
 
960
960
  var bytes = read_stdin(timeout_ms)?
961
- defer bytes.release()
961
+ defer: bytes.release()
962
962
  if not bytes.is_empty():
963
963
  this.input.append_span(bytes.as_span())
964
964
 
data/std/tls.mt CHANGED
@@ -335,7 +335,7 @@ function end_stream_operation(state: ptr[StreamState]) -> void:
335
335
 
336
336
  async function handshake_on(runtime: aio.Runtime, state_raw: ptr[StreamState]?) -> Result[bool, Error]:
337
337
  let state = begin_stream_operation(state_raw)?
338
- defer end_stream_operation(state)
338
+ defer: end_stream_operation(state)
339
339
 
340
340
  while true:
341
341
  let client = unsafe: read(state).client else:
@@ -366,7 +366,7 @@ async function write_on(
366
366
  return Result[ptr_uint, Error].success(value = 0)
367
367
 
368
368
  let state = begin_stream_operation(state_raw)?
369
- defer end_stream_operation(state)
369
+ defer: end_stream_operation(state)
370
370
 
371
371
  var offset: ptr_uint = 0
372
372
  while offset < content.len:
@@ -411,7 +411,7 @@ async function read_once_on(
411
411
  return Result[bytes.Bytes, Error].failure(error = tls_error("tls read requires max_bytes > 0"))
412
412
 
413
413
  let state = begin_stream_operation(state_raw)?
414
- defer end_stream_operation(state)
414
+ defer: end_stream_operation(state)
415
415
 
416
416
  let buffer = heap.must_alloc[ubyte](max_bytes)
417
417
  while true:
@@ -449,7 +449,7 @@ async function read_once_on(
449
449
 
450
450
  async function shutdown_on(runtime: aio.Runtime, state_raw: ptr[StreamState]?) -> Result[bool, Error]:
451
451
  let state = begin_stream_operation(state_raw)?
452
- defer end_stream_operation(state)
452
+ defer: end_stream_operation(state)
453
453
 
454
454
  while true:
455
455
  let client = unsafe: read(state).client else:
@@ -470,7 +470,7 @@ async function shutdown_on(runtime: aio.Runtime, state_raw: ptr[StreamState]?) -
470
470
 
471
471
  public async function connect_on(runtime: aio.Runtime, host: str, port: int) -> Result[Stream, Error]:
472
472
  var service = fmt.to_string_int(port)
473
- defer service.release()
473
+ defer: service.release()
474
474
 
475
475
  let addresses_result = await net.resolve_all_on(runtime, host, service.as_str())
476
476
  match addresses_result:
@@ -478,7 +478,7 @@ public async function connect_on(runtime: aio.Runtime, host: str, port: int) ->
478
478
  return Result[Stream, Error].failure(error = take_net_error(payload.error))
479
479
  Result.success as payload:
480
480
  var addresses = payload.value
481
- defer release_socket_addresses(ref_of(addresses))
481
+ defer: release_socket_addresses(ref_of(addresses))
482
482
 
483
483
  var last_error = tls_error("tls connect failed")
484
484
  var last_error_owned = true
@@ -523,7 +523,7 @@ public async function client_on(runtime: aio.Runtime, host: str, transport: net.
523
523
  Result.success as payload:
524
524
  var raw_client: ptr[c.mt_tls_client]? = null
525
525
  var host_storage = arena.create(host.len + 1)
526
- defer host_storage.release()
526
+ defer: host_storage.release()
527
527
 
528
528
  var raw_error = zero[c.mt_tls_error]
529
529
  let create_status = c.mt_tls_client_create(host_storage.to_cstr(host), payload.value, raw_client, raw_error)
@@ -598,7 +598,7 @@ extending Stream:
598
598
 
599
599
  public function exchange(host: str, port: int, request: span[ubyte]) -> Result[bytes.Bytes, Error]:
600
600
  var host_storage = arena.create(host.len + 1)
601
- defer host_storage.release()
601
+ defer: host_storage.release()
602
602
 
603
603
  var raw_response = zero[c.mt_tls_bytes]
604
604
  var raw_error = zero[c.mt_tls_error]
data/std/uri.mt CHANGED
@@ -7,7 +7,7 @@ const FILE_URI_PREFIX: str = "file://"
7
7
 
8
8
  public function file_uri_from_path(path_text: str) -> string.String:
9
9
  var normalized = path.normalize_separators(path_text)
10
- defer normalized.release()
10
+ defer: normalized.release()
11
11
 
12
12
  var result = string.String.from_str(FILE_URI_PREFIX)
13
13
  append_percent_encoded_path(ref_of(result), normalized.as_str())
data/std/utility.mt CHANGED
@@ -152,7 +152,7 @@ extending Action[Context]:
152
152
  return 0.0
153
153
 
154
154
  var scores = vec.Vec[float].with_capacity(n)
155
- defer scores.release()
155
+ defer: scores.release()
156
156
 
157
157
  for entry in this.considerations:
158
158
  unsafe:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mt-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.13
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Long (Teefan) Tran
@@ -405,6 +405,7 @@ files:
405
405
  - std/binary_heap.mt
406
406
  - std/bitset.mt
407
407
  - std/blackboard.mt
408
+ - std/box.mt
408
409
  - std/box2d.mt
409
410
  - std/bytes.mt
410
411
  - std/c/box2d.mt
@@ -463,7 +464,6 @@ files:
463
464
  - std/c/zlib.mt
464
465
  - std/c/zlib_support.h
465
466
  - std/c/zstd.mt
466
- - std/cell.mt
467
467
  - std/cgltf.mt
468
468
  - std/cjson.mt
469
469
  - std/cli.mt
@@ -605,7 +605,7 @@ metadata:
605
605
  homepage_uri: https://teefan.github.io/mt-lang/
606
606
  source_code_uri: https://github.com/teefan/mt-lang
607
607
  post_install_message: |
608
- Milk Tea 0.3.13 installed!
608
+ Milk Tea 0.3.16 installed!
609
609
 
610
610
  System requirements:
611
611
  - A C compiler (gcc or clang) must be available on PATH