mt-lang 0.4.23 → 0.4.25

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 (62) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +8 -8
  5. data/lib/milk_tea/base.rb +1 -1
  6. data/lib/milk_tea/core/control_flow/builder.rb +12 -0
  7. data/lib/milk_tea/core/types/layout.rb +90 -19
  8. data/lib/milk_tea/tooling/cli/commands/std.rb +84 -0
  9. data/lib/milk_tea/tooling/cli.rb +25 -0
  10. data/lib/milk_tea/tooling/linter/fix_engine.rb +100 -0
  11. data/lib/milk_tea/tooling/linter/release_rules.rb +69 -11
  12. data/lib/milk_tea/tooling/linter/visitors.rb +58 -31
  13. data/lib/milk_tea/tooling/linter.rb +8 -1
  14. data/lib/milk_tea/tooling/std_catalog.rb +277 -0
  15. data/lib/milk_tea/tooling.rb +1 -0
  16. data/std/async/libuv_runtime.mt +20 -23
  17. data/std/async/mailbox.mt +2 -2
  18. data/std/base64.mt +3 -6
  19. data/std/behavior_tree.mt +1 -6
  20. data/std/binary.mt +2 -5
  21. data/std/color.mt +20 -20
  22. data/std/cookie.mt +1 -4
  23. data/std/deque.mt +2 -8
  24. data/std/encoding.mt +1 -4
  25. data/std/fmt.mt +1 -4
  26. data/std/graph.mt +5 -1
  27. data/std/htn.mt +9 -1
  28. data/std/http/server.mt +1 -4
  29. data/std/http.mt +14 -17
  30. data/std/jobs.mt +9 -10
  31. data/std/json.mt +17 -28
  32. data/std/linked_map.mt +3 -9
  33. data/std/map.mt +1 -4
  34. data/std/net/channel.mt +6 -6
  35. data/std/net/lobby.mt +3 -3
  36. data/std/net/manager.mt +0 -1
  37. data/std/net/mux.mt +1 -1
  38. data/std/net/packet.mt +4 -1
  39. data/std/net/punch.mt +3 -2
  40. data/std/net/rpc.mt +1 -3
  41. data/std/net/session.mt +12 -25
  42. data/std/net/sync.mt +3 -3
  43. data/std/net/turn.mt +7 -3
  44. data/std/net.mt +145 -159
  45. data/std/noise.mt +11 -7
  46. data/std/ordered_map.mt +2 -8
  47. data/std/ordered_set.mt +3 -5
  48. data/std/path.mt +1 -4
  49. data/std/process.mt +7 -18
  50. data/std/random.mt +2 -2
  51. data/std/sdl3/runtime.mt +1 -1
  52. data/std/steering.mt +27 -4
  53. data/std/string.mt +1 -4
  54. data/std/tar.mt +8 -10
  55. data/std/terminal.mt +21 -40
  56. data/std/thread.mt +3 -4
  57. data/std/tls.mt +22 -29
  58. data/std/toml.mt +23 -31
  59. data/std/uri.mt +2 -1
  60. data/std/utility.mt +2 -2
  61. data/std/vec.mt +8 -17
  62. metadata +5 -3
data/std/net/session.mt CHANGED
@@ -169,7 +169,10 @@ function generate_handshake_key() -> Result[ulong, net.Error]:
169
169
 
170
170
  function decode_uint_at(data: span[ubyte], offset: ptr_uint) -> uint:
171
171
  unsafe:
172
- return uint<-read(data.data + offset) | (uint<-read(data.data + offset + 1) << 8) | (uint<-read(data.data + offset + 2) << 16) | (uint<-read(data.data + offset + 3) << 24)
172
+ return uint<-read(data.data + offset) |
173
+ (uint<-read(data.data + offset + 1) << 8) |
174
+ (uint<-read(data.data + offset + 2) << 16) |
175
+ (uint<-read(data.data + offset + 3) << 24)
173
176
 
174
177
 
175
178
  function channel_config_for(config: Config) -> chan.Config:
@@ -315,9 +318,7 @@ extending Connection:
315
318
  defer: hb.release()
316
319
  let send_result = await this.channel.send(hb.as_span())
317
320
  match send_result:
318
- Result.failure:
319
- pass
320
- Result.success:
321
+ Result.failure | Result.success:
321
322
  pass
322
323
  this.last_heartbeat_sent = frame
323
324
 
@@ -327,9 +328,7 @@ extending Connection:
327
328
 
328
329
  let channel_tick_result = await this.channel.tick(frame)
329
330
  match channel_tick_result:
330
- Result.failure:
331
- pass
332
- Result.success:
331
+ Result.failure | Result.success:
333
332
  pass
334
333
 
335
334
  await aio.sleep(1)
@@ -467,9 +466,7 @@ extending Connection:
467
466
  let send_result = await this.channel.send_reliable(d.as_span(), 0)
468
467
  this.state = ConnectionState.disconnected
469
468
  match send_result:
470
- Result.failure:
471
- return Result[bool, net.Error].success(value = true)
472
- Result.success:
469
+ Result.failure | Result.success:
473
470
  return Result[bool, net.Error].success(value = true)
474
471
 
475
472
 
@@ -657,9 +654,7 @@ extending Session:
657
654
  defer: addr.release()
658
655
  let send_result = await this.host.send(addr, hb.as_span())
659
656
  match send_result:
660
- Result.failure:
661
- pass
662
- Result.success:
657
+ Result.failure | Result.success:
663
658
  pass
664
659
  Result.failure:
665
660
  pass
@@ -680,9 +675,7 @@ extending Session:
680
675
 
681
676
  let host_tick_result = await this.host.tick(frame)
682
677
  match host_tick_result:
683
- Result.failure:
684
- pass
685
- Result.success:
678
+ Result.failure | Result.success:
686
679
  pass
687
680
 
688
681
  await aio.sleep(1)
@@ -799,9 +792,7 @@ extending Session:
799
792
  defer: d.release()
800
793
  let send_result = await this.host.send_reliable(address, d.as_span(), 0)
801
794
  match send_result:
802
- Result.failure:
803
- pass
804
- Result.success:
795
+ Result.failure | Result.success:
805
796
  pass
806
797
  mark_peer_disconnected(ref_of(this), peer_id)
807
798
  this.event_queue.push_back(PeerEvent(
@@ -1062,9 +1053,7 @@ async function drain_outgoing_session(session: ref[Session]) -> Result[bool, net
1062
1053
  0
1063
1054
  )
1064
1055
  match send_result:
1065
- Result.failure:
1066
- pass
1067
- Result.success:
1056
+ Result.failure | Result.success:
1068
1057
  pass
1069
1058
  else:
1070
1059
  let send_result = await session.host.send(
@@ -1072,9 +1061,7 @@ async function drain_outgoing_session(session: ref[Session]) -> Result[bool, net
1072
1061
  outgoing.payload.as_span()
1073
1062
  )
1074
1063
  match send_result:
1075
- Result.failure:
1076
- pass
1077
- Result.success:
1064
+ Result.failure | Result.success:
1078
1065
  pass
1079
1066
 
1080
1067
 
data/std/net/sync.mt CHANGED
@@ -107,7 +107,7 @@ extending CompressedUshort:
107
107
 
108
108
 
109
109
  public function decode(encoded: ushort) -> float:
110
- let ratio = float<-encoded / 65535.0
110
+ let ratio = encoded / 65535.0
111
111
  return this.min + ratio * (this.max - this.min)
112
112
 
113
113
  public struct CompressedUbyte:
@@ -127,7 +127,7 @@ extending CompressedUbyte:
127
127
 
128
128
 
129
129
  public function decode(encoded: ubyte) -> float:
130
- let ratio = float<-encoded / 255.0
130
+ let ratio = encoded / 255.0
131
131
  return this.min + ratio * (this.max - this.min)
132
132
 
133
133
  public struct TickBuffer[T]:
@@ -138,7 +138,7 @@ public struct TickBuffer[T]:
138
138
  extending TickBuffer[T]:
139
139
  public editable function push(tick: uint, value: T) -> void:
140
140
  let offset: ptr_uint = ptr_uint<-(tick - this.base_tick)
141
- while offset >= this.entries.len():
141
+ if offset >= this.entries.len():
142
142
  this.entries.push(value)
143
143
  return
144
144
  let ptr = this.entries.get(offset) else:
data/std/net/turn.mt CHANGED
@@ -342,9 +342,11 @@ public function parse_data_indication(
342
342
  var attr_len: ptr_uint = read_ushort_be(data, 2z)
343
343
  var offset: ptr_uint = turn_header_len
344
344
  var found_peer: bool = false
345
- var peer_addr: net.SocketAddress = zero[net.SocketAddress]
345
+ # Ownership is tracked manually here: both bindings are released on the
346
+ # failure path below and moved into TurnDatagram on success.
347
+ var peer_addr: net.SocketAddress = zero[net.SocketAddress] # lint: ignore(owning-release-leak)
346
348
  var found_data: bool = false
347
- var payload: bytes.Bytes = bytes.Bytes.empty()
349
+ var payload: bytes.Bytes = bytes.Bytes.empty() # lint: ignore(owning-release-leak)
348
350
 
349
351
  while attr_len >= 4z:
350
352
  if offset + 4z > data.len:
@@ -387,6 +389,8 @@ public function parse_data_indication(
387
389
  if not found_peer or not found_data:
388
390
  if found_data:
389
391
  payload.release()
392
+ if found_peer:
393
+ peer_addr.release()
390
394
  return Result[TurnDatagram, Error].failure(
391
395
  error = turn_error(err_no_data_attribute, "data indication missing attributes")
392
396
  )
@@ -420,7 +424,7 @@ public async function send_data(
420
424
  defer: packet.release()
421
425
  let send_result = await socket.send_to(packet.as_span(), turn_server)
422
426
  match send_result:
423
- Result.failure as sp:
427
+ Result.failure:
424
428
  return Result[ptr_uint, Error].failure(
425
429
  error = turn_error(err_send_failed, "send indication failed")
426
430
  )