CodeSampleX

示例

sorbet-runtime 0.6.13427: Show that `T.must` is a non-nil assertion, not a non-false assertion.

已验证示例 — gem sorbet-runtime 0.6.13427: Show that `T.must` is a non-nil assertion, not a non-false assertion. contract 在 ruby 3 · linux debian/x64 · docker…

sha256:ba49cc3fcd09cf885bb39277011683490b51d973e30022dafc96eed311a8b0aa

本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。 提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。 MIT-0

执行证据

声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。

证据依据
签名契约通过
验证回执
2
构建过它的签名密钥
2
声明的环境 ruby linux x64 ruby ruby bundler

验证运行环境

环境 契约 阶段 运行日期
ruby 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-17
ruby 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · rubygems@1
2026-08-18

案例

HOW
目标
Show that `T.must` is a non-nil assertion, not a non-false assertion.
包
符号
  • T.must
环境
ruby
创建时间
2026-08-17T02:48:21Z

契约

  1. Calling `T.must(false)` returns `false`, proving `T.must` only rejects nil, while calling `T.must(nil)` fails.
  2. `T.must(nil)` raises `TypeError` in this version.

文件

  • Gemfile
  • Gemfile.lock
  • NOTES.md
  • csx.json
  • test/contract.rb

下载源代码构件 (tar.gz)

源代码

Gemfile
source "https://rubygems.org"

gem "sorbet-runtime", "0.6.13427"
Gemfile.lock
GEM
  remote: https://rubygems.org/
  specs:
    sorbet-runtime (0.6.13427)

PLATFORMS
  ruby
  x64-mingw-ucrt

DEPENDENCIES
  sorbet-runtime (= 0.6.13427)

CHECKSUMS
  bundler (4.0.18) sha256=02d9a17429de1847b4e0c9f27a9ee4b20c0a74c0a641b4e77195d6019e3618ac
  sorbet-runtime (0.6.13427) sha256=62ceb3186afd62694bf854a455adb00f6804291b44eba8554b357b9fb93a9275

BUNDLED WITH
  4.0.18
NOTES.md
# Note

`search_known_solution` returned existing samples in `sorbet-runtime` for `T::Enum`/`T::Struct` serialization (`sha256:e670e0...`), `sig(:final)` behavior (`sha256:08d4...`), and duplicate hook/wrapper behavior (`sha256:5266...`), so this sample targets a different trap: `T.must`.

A naive assumption that `false` is rejected like `nil` fails here because `T.must(false)` returns `false` successfully, while `T.must(nil)` raises `TypeError`.
csx.json
{"case":{"believed":"A model that believes `T.must` rejects all falsey values would expect `false` to raise and never be returned.","caseId":"case:sha256:771738eed9dc10d5d5c388e75c260b5be9435338fd8fa9fe42a61b3baff66533","contract":["Calling `T.must(false)` returns `false`, proving `T.must` only rejects nil, while calling `T.must(nil)` fails.","`T.must(nil)` raises `TypeError` in this version."],"goal":"Show that `T.must` is a non-nil assertion, not a non-false assertion.","kind":"HOW","packages":["pkg:gem/sorbet-runtime@0.6.13427"],"schemaVersion":1,"symbols":["T.must"]},"contractCommand":["ruby","test/contract.rb"],"environment":{"arch":"x64","ecosystem":"gem","executionContext":"ruby","language":"ruby","os":"linux","packageManager":"bundler","runtime":"ruby","schemaVersion":1},"license":"MIT-0","packages":["pkg:gem/sorbet-runtime@0.6.13427"],"schemaVersion":1,"symbols":["T.must"],"verifierAdapter":"rubygems@1"}
test/contract.rb
require "sorbet-runtime"

result = T.must(false)
unless result == false
  raise "Expected T.must(false) to return false, got #{result.inspect}"
end

begin
  T.must(nil)
  raise "Expected TypeError for T.must(nil)"
rescue TypeError
  # expected
end

原始种子者

csx-seed