型別メソッドカバレッジ — ConstantFolding / ShapeDispatch / ExpressionTyper 監査
2026-05-22生成。Ruby 4.0の"".methods - Object.new.methods等から型ごとに固有メソッドを抽出し、現在の精度カバレッジを分類する。
| 記号 | 意味 |
|---|---|
| ✅ | ConstantFolding(invoke_unary/invoke_binary)またはShapeDispatch / ExpressionTyperブロックフォールドで実装済み |
| 🔷 | 別ティア処理済み(BlockFolding / LiteralStringFolding / RBSで十分精度が出る) |
| 🔲 | 未実装だが精度向上の価値あり |
| 🚫 | 非対象(破壊的変更・Enumerator生成・精度向上がnegligible) |
1. String
Section titled “1. String”Constant[String]はSTRING_UNARY / STRING_BINARYで処理。
特殊ケース: % → try_fold_string_format、chars/bytes/lines/split → try_fold_string_array_unary/_binary。
<</concat / +(リテラル文字列連結)→ LiteralStringFolding。
1-1. メソッド一覧
Section titled “1-1. メソッド一覧”| メソッド | 状態 | 備考 |
|---|---|---|
% | ✅ | try_fold_string_format — Tuple / HashShape引数対応。 |
* | ✅ | STRING_BINARY — Constant["ab"] * 3 → Constant["ababab"]。 |
+ | ✅ | STRING_BINARY。リテラル連結はLiteralStringFoldingも担当。 |
<< | 🔷 | LiteralStringFoldingでliteral-string精度維持。破壊的変更。 |
<=> | ✅ | STRING_BINARY → Constant[Integer]。 |
<, <=, >, >=, ==, != | ✅ | STRING_BINARY → Constant[bool]。 |
[] / slice | 🔲 | 整数インデックスまたはRange引数で`Constant[String |
ascii_only? | 🔲 | STRING_UNARY追加でConstant[bool]。低優先度。 |
b | 🚫 | BINARYエンコーディングで複製。精度向上なし。 |
bytesize | ✅ | STRING_UNARY → Constant[Integer]。 |
bytes | ✅ | try_fold_string_array_unary → Tuple[Constant[Integer]…]。 |
capitalize | ✅ | STRING_UNARY → Constant[String]。 |
capitalize! | 🚫 | 破壊的変更。 |
casecmp | 🔲 | STRING_BINARY追加で`Constant[Integer |
casecmp? | 🔲 | STRING_BINARY追加で`Constant[bool |
center | 🔲 | STRING_BINARY追加でConstant[String]。中優先度。 |
chars | ✅ | try_fold_string_array_unary → Tuple[Constant[String]…]。 |
chomp | ✅ | STRING_UNARY → Constant[String]。 |
chomp! | 🚫 | 破壊的変更。 |
chop | 🔲 | STRING_UNARY追加でConstant[String]。中優先度。 |
chop! | 🚫 | 破壊的変更。 |
chr | 🔲 | STRING_UNARY追加でConstant[String](最初の1文字)。中優先度。 |
clear | 🚫 | 破壊的変更。 |
concat | 🔷 | LiteralStringFoldingでliteral-string精度維持。 |
count | 🔲 | STRING_BINARY追加でConstant[Integer](文字数カウント)。低優先度。 |
delete | 🔲 | STRING_BINARY追加でConstant[String]。低優先度。 |
delete! | 🚫 | 破壊的変更。 |
delete_prefix | ✅ | STRING_BINARY追加でConstant[String]。高優先度。 |
delete_prefix! | 🚫 | 破壊的変更。 |
delete_suffix | ✅ | STRING_BINARY追加でConstant[String]。高優先度。 |
delete_suffix! | 🚫 | 破壊的変更。 |
downcase | ✅ | STRING_UNARY → Constant[String]。 |
downcase! | 🚫 | 破壊的変更。 |
dump | 🔲 | STRING_UNARY追加でConstant[String]。低優先度。 |
each_byte / each_char / each_line / each_codepoint | 🚫 | 反復子 / Enumerator。 |
empty? | ✅ | STRING_UNARY → Constant[bool]。 |
encode | 🔲 | エンコーディング引数あり。中優先度。 |
encode! | 🚫 | 破壊的変更。 |
encoding | 🔲 | STRING_UNARY追加でConstant[Encoding]。低優先度。 |
end_with? | ✅ | STRING_BINARY追加でConstant[bool]。高優先度。 |
force_encoding | 🚫 | 破壊的変更(エンコーディング変更)。 |
gsub | 🔲 | Regexp引数で複雑。低優先度。 |
gsub! | 🚫 | 破壊的変更。 |
hash | ✅ | STRING_UNARY → Constant[Integer]。 |
hex | 🔲 | STRING_UNARY追加でConstant[Integer]。中優先度。 |
include? | ✅ | STRING_BINARY追加でConstant[bool]。高優先度。 |
index | 🔲 | STRING_BINARY追加で`Constant[Integer |
insert | 🚫 | 破壊的変更。 |
inspect | ✅ | STRING_UNARY → Constant[String]。 |
intern / to_sym | ✅ | STRING_UNARY → Constant[Symbol]。 |
length / size | ✅ | STRING_UNARY → Constant[Integer]。 |
lines | ✅ | try_fold_string_array_unary → Tuple[Constant[String]…]。 |
ljust | 🔲 | STRING_BINARY追加でConstant[String]。中優先度。 |
lstrip | ✅ | STRING_UNARY → Constant[String]。 |
lstrip! | 🚫 | 破壊的変更。 |
match | 🔲 | Regexp引数、`MatchData |
match? | 🔲 | STRING_BINARY追加でConstant[bool]。中優先度。 |
next / succ | 🔲 | STRING_UNARY追加でConstant[String]。中優先度。 |
next! / succ! | 🚫 | 破壊的変更。 |
oct | 🔲 | STRING_UNARY追加でConstant[Integer]。中優先度。 |
ord | ✅ | STRING_UNARY追加でConstant[Integer](最初のコードポイント)。高優先度。 |
prepend | 🚫 | 破壊的変更。 |
replace | 🚫 | 破壊的変更。 |
reverse | ✅ | STRING_UNARY → Constant[String]。 |
reverse! | 🚫 | 破壊的変更。 |
rindex | 🔲 | STRING_BINARY追加で`Constant[Integer |
rjust | 🔲 | STRING_BINARY追加でConstant[String]。中優先度。 |
rstrip | ✅ | STRING_UNARY → Constant[String]。 |
rstrip! | 🚫 | 破壊的変更。 |
scan | ✅ | try_fold_string_array_binary → Tuple[Constant[String]…]。 |
scrub | 🔲 | STRING_UNARY追加でConstant[String]。低優先度。 |
split | ✅ | try_fold_string_array_unary / _binary対応。 |
squeeze | 🔲 | STRING_UNARY追加でConstant[String]。低優先度。 |
start_with? | ✅ | STRING_BINARY追加でConstant[bool]。高優先度。 |
strip | ✅ | STRING_UNARY → Constant[String]。 |
strip! | 🚫 | 破壊的変更。 |
sub | 🔲 | Regexp引数で複雑。低優先度。 |
sub! | 🚫 | 破壊的変更。 |
swapcase | ✅ | STRING_UNARY → Constant[String]。 |
swapcase! | 🚫 | 破壊的変更。 |
to_c | 🔲 | STRING_UNARY追加でConstant[Complex]。低優先度。 |
to_f | ✅ | STRING_UNARY追加でConstant[Float]。高優先度。 |
to_i | ✅ | STRING_UNARY追加でConstant[Integer]。高優先度。 |
to_r | 🔲 | STRING_UNARY追加でConstant[Rational]。低優先度。 |
to_s / to_str | ✅ | STRING_UNARY → Constant[String]。 |
tr | 🔲 | 文字置換。低優先度。 |
tr! | 🚫 | 破壊的変更。 |
undump | 🔲 | STRING_UNARY追加でConstant[String]。低優先度。 |
unicode_normalize | 🔲 | STRING_UNARY追加でConstant[String]。低優先度。 |
upcase | ✅ | STRING_UNARY → Constant[String]。 |
upcase! | 🚫 | 破壊的変更。 |
upto | 🚫 | Enumerator。 |
valid_encoding? | 🔲 | STRING_UNARY追加でConstant[bool]。低優先度。 |
1-2. 実装チェックリスト(優先度順)
Section titled “1-2. 実装チェックリスト(優先度順)”高優先度(Constant[String] / Constant[bool] への折りたたみで頻用パターンをカバー):[x] start_with? → STRING_BINARY に追加 → Constant[bool][x] end_with? → STRING_BINARY に追加 → Constant[bool][x] include? → STRING_BINARY に追加 → Constant[bool][x] delete_prefix → STRING_BINARY に追加 → Constant[String][x] delete_suffix → STRING_BINARY に追加 → Constant[String][x] to_i → STRING_UNARY に追加 → Constant[Integer][x] to_f → STRING_UNARY に追加 → Constant[Float][x] ord → STRING_UNARY に追加 → Constant[Integer]
中優先度:[x] chr → STRING_UNARY に追加 → Constant[String][x] hex → STRING_UNARY に追加 → Constant[Integer][x] oct → STRING_UNARY に追加 → Constant[Integer][x] next / succ → STRING_UNARY に追加 → Constant[String][x] chop → STRING_UNARY に追加 → Constant[String][x] match? → STRING_BINARY に追加 → Constant[bool][x] index → STRING_BINARY に追加 → Constant[Integer|nil][x] rindex → STRING_BINARY に追加 → Constant[Integer|nil][x] center → STRING_BINARY に追加 → Constant[String](幅ブローアップガード付き)[x] ljust / rjust → STRING_BINARY に追加 → Constant[String](同上)
低優先度:[ ] casecmp / casecmp? → STRING_BINARY[ ] count (文字カウント) → STRING_BINARY[ ] delete → STRING_BINARY[ ] ascii_only? → STRING_UNARY[ ] encoding → STRING_UNARY[ ] squeeze → STRING_UNARY[ ] valid_encoding? → STRING_UNARY[ ] [] / slice → 専用ハンドラ(整数インデックス / Range 引数)実装ファイル: lib/rigor/inference/method_dispatcher/constant_folding.rbのSTRING_UNARY / STRING_BINARY。
2. Integer
Section titled “2. Integer”Constant[Integer]はINTEGER_UNARY / NUMERIC_BINARYで処理。
IntegerRange向け専用ハンドラ群は別途shape_dispatch.rbに存在。
2-1. メソッド一覧
Section titled “2-1. メソッド一覧”| メソッド | 状態 | 備考 |
|---|---|---|
+, -, *, /, % | ✅ | NUMERIC_BINARY → `Constant[Integer |
** | ✅ | NUMERIC_BINARY追加で`Constant[Integer |
&, ` | , ^` | ✅ |
<<, >> | ✅ | NUMERIC_BINARY追加でConstant[Integer]。カタログでもカバー済み。 |
~ | ✅ | INTEGER_UNARY → Constant[Integer]。 |
<=>, <, <=, >, >=, ==, != | ✅ | NUMERIC_BINARY → `Constant[Integer |
-@, +@ | ✅ | INTEGER_UNARY。 |
abs / magnitude | ✅ | INTEGER_UNARY → Constant[Integer]。 |
bit_length | ✅ | INTEGER_UNARY → Constant[Integer]。 |
between? | ✅ | try_fold_ternary(catalog経由)→ Constant[bool]。 |
ceil | ✅ | INTEGER_UNARY(引数なし)→ Constant[Integer]。 |
chr | ✅ | INTEGER_UNARY → Constant[String]。 |
clamp | ✅ | try_fold_ternary(catalog経由)→ Constant[Integer]。 |
coerce | 🚫 | 内部用。精度向上なし。 |
digits | ✅ | try_fold_integer_array_unary → Tuple[Constant[Integer]…]。 |
divmod | ✅ | try_fold_divmod → Tuple[Constant[Integer], Constant[Integer]]。 |
even? | ✅ | INTEGER_UNARY → Constant[bool]。 |
fdiv | ✅ | NUMERIC_BINARY → Constant[Float]。 |
floor | ✅ | INTEGER_UNARY(引数なし)→ Constant[Integer]。 |
gcd | ✅ | NUMERIC_BINARY → Constant[Integer]。 |
gcdlcm | 🔲 | INTEGER_BINARY追加でTuple[Constant[Integer], Constant[Integer]]。低優先度。 |
hash | ✅ | INTEGER_UNARY → Constant[Integer]。 |
inspect / to_s | ✅ | INTEGER_UNARY → Constant[String]。 |
integer? | 🔲 | INTEGER_UNARY追加でConstant[true]。低優先度(常にtrue)。 |
lcm | ✅ | NUMERIC_BINARY → Constant[Integer]。 |
negative? / positive? / zero? | ✅ | INTEGER_UNARY → Constant[bool]。 |
next / succ | ✅ | INTEGER_UNARY → Constant[Integer]。 |
odd? | ✅ | INTEGER_UNARY → Constant[bool]。 |
pow | 🔲 | **の別名(ただしpow(exp, mod)は剰余乗算)。低優先度。 |
pred | ✅ | INTEGER_UNARY → Constant[Integer]。 |
rationalize / to_r | 🔲 | INTEGER_UNARY追加でConstant[Rational]。低優先度。 |
round | ✅ | INTEGER_UNARY(引数なし)→ Constant[Integer]。 |
size | 🔲 | プラットフォーム依存バイト幅。低優先度。 |
to_c | 🔲 | INTEGER_UNARY追加でConstant[Complex]。低優先度。 |
to_f | ✅ | INTEGER_UNARY → Constant[Float]。 |
to_i / to_int | ✅ | INTEGER_UNARY → Constant[Integer]。 |
truncate | ✅ | INTEGER_UNARY(引数なし)→ Constant[Integer]。 |
upto / downto / times | 🚫 | 反復子。 |
2-2. 実装チェックリスト(優先度順)
Section titled “2-2. 実装チェックリスト(優先度順)”高優先度(式で多用・Constant[Integer] 精度の核心):[x] ** → NUMERIC_BINARY → Constant[Integer|Float][x] & → NUMERIC_BINARY → Constant[Integer][x] | → NUMERIC_BINARY → Constant[Integer][x] ^ → NUMERIC_BINARY → Constant[Integer][x] << → NUMERIC_BINARY → Constant[Integer][x] >> → NUMERIC_BINARY → Constant[Integer]
中優先度:[x] floor / ceil / round / truncate (引数なし) → INTEGER_UNARY → Constant[Integer][x] chr → INTEGER_UNARY → Constant[String][x] digits (引数なし) → try_fold_integer_array_unary → Tuple[Constant[Integer]…][x] gcd / lcm → NUMERIC_BINARY → Constant[Integer][x] divmod → try_fold_divmod → Tuple[Constant[Integer], Constant[Integer]][x] fdiv → NUMERIC_BINARY → Constant[Float][x] between? → try_fold_ternary(catalog 経由)→ Constant[bool][x] clamp → try_fold_ternary(catalog 経由)→ Constant[Integer]
低優先度:[ ] rationalize / to_r → INTEGER_UNARY[ ] gcdlcm → INTEGER_BINARY[ ] pow(exp, mod) → 専用ハンドラ(3 引数形式)実装ファイル: constant_folding.rbのINTEGER_UNARY拡張、またはNUMERIC_BINARYへのキー追加。
invoke_binaryはConstant[Integer] op Constant[Integer]のとき自動評価するので定数に追加するだけで折りたたみが機能する。
3. Float
Section titled “3. Float”Constant[Float]はFLOAT_UNARY / NUMERIC_BINARYで処理。
3-1. メソッド一覧
Section titled “3-1. メソッド一覧”| メソッド | 状態 | 備考 |
|---|---|---|
+, -, *, /, % | ✅ | NUMERIC_BINARY。 |
** | ✅ | NUMERIC_BINARY追加でConstant[Float]。高優先度。 |
<=>, <, <=, >, >=, ==, != | ✅ | NUMERIC_BINARY → `Constant[bool |
-@, +@ | ✅ | FLOAT_UNARY。 |
abs / magnitude | ✅ | FLOAT_UNARY → Constant[Float]。 |
between? | ✅ | try_fold_ternary(catalog経由)→ Constant[bool]。 |
ceil | ✅ | FLOAT_UNARY(引数なし)→ Constant[Integer]。 |
ceil(n) | 🔲 | 小数点指定形式の専用ハンドラ → Constant[Float]。低優先度。 |
clamp | ✅ | try_fold_ternary(catalog経由)→ Constant[Float]。 |
coerce | 🚫 | 内部用。 |
divmod | ✅ | try_fold_divmod → Tuple[Constant[Integer], Constant[Float]]。 |
fdiv | ✅ | NUMERIC_BINARY → Constant[Float]。 |
finite? | ✅ | FLOAT_UNARY → Constant[bool]。 |
floor | ✅ | FLOAT_UNARY(引数なし)→ Constant[Integer]。 |
floor(n) | 🔲 | 小数点指定形式 → Constant[Float]。低優先度。 |
hash | ✅ | FLOAT_UNARY → Constant[Integer]。 |
infinite? | ✅ | FLOAT_UNARY → Constant[Integer](-1/0/1)。 |
inspect / to_s | ✅ | FLOAT_UNARY → Constant[String]。 |
modulo | 🔷 | %の別名 → NUMERIC_BINARYで処理。 |
nan? | ✅ | FLOAT_UNARY → Constant[bool]。 |
negative? / positive? / zero? | ✅ | FLOAT_UNARY → Constant[bool]。 |
next_float | ✅ | FLOAT_UNARY → Constant[Float]。 |
prev_float | ✅ | FLOAT_UNARY → Constant[Float]。 |
rationalize / to_r | 🔲 | FLOAT_UNARY追加でConstant[Rational]。低優先度。 |
round | ✅ | FLOAT_UNARY(引数なし)→ Constant[Integer]。 |
round(n) | 🔲 | 小数点指定形式 → Constant[Float]。低優先度。 |
to_c | 🔲 | FLOAT_UNARY追加でConstant[Complex]。低優先度。 |
to_f | ✅ | FLOAT_UNARY → Constant[Float]。 |
to_i / to_int / truncate | ✅ | FLOAT_UNARY → Constant[Integer]。 |
3-2. 実装チェックリスト(優先度順)
Section titled “3-2. 実装チェックリスト(優先度順)”高優先度:[x] ** → NUMERIC_BINARY → Constant[Float]
中優先度:[x] divmod → try_fold_divmod → Tuple[Constant[Integer], Constant[Float]][x] between? → try_fold_ternary(catalog 経由)→ Constant[bool][x] clamp → try_fold_ternary(catalog 経由)→ Constant[Float]
低優先度:[ ] ceil(n) / floor(n) / round(n) → 小数点 n 指定形式専用ハンドラ[x] next_float / prev_float → FLOAT_UNARY[x] fdiv → NUMERIC_BINARY[ ] rationalize / to_r / to_c → FLOAT_UNARY実装ファイル: constant_folding.rbのFLOAT_UNARY拡張 / NUMERIC_BINARY追加。
4. bool(TrueClass / FalseClass)
Section titled “4. bool(TrueClass / FalseClass)”Constant[true] / Constant[false]はBOOL_UNARY / BOOL_BINARYで処理。
カバレッジはほぼ完全。
4-1. メソッド一覧
Section titled “4-1. メソッド一覧”(true.methods - Object.new.methods).sort → [:&, :^, :|](TrueClass / FalseClass共通)。
| メソッド | 状態 | 備考 |
|---|---|---|
& | ✅ | BOOL_UNARY(引数なし形式)・BOOL_BINARY → Constant[bool]。 |
| ` | ` | ✅ |
^ | ✅ | 同上。 |
! | ✅ | BOOL_UNARY → Constant[bool](論理反転)。 |
==, != | ✅ | BOOL_BINARY → Constant[bool]。 |
to_s / inspect / hash | ✅ | BOOL_UNARY → 各Constant型。 |
=== | ✅ | BOOL_BINARY追加でConstant[bool]。低優先度(==と等価な場面がほとんど)。 |
4-2. 実装チェックリスト
Section titled “4-2. 実装チェックリスト”低優先度(現状カバレッジほぼ完全):[x] === → BOOL_BINARY に追加 → Constant[bool]5. Array(Tupleキャリア)
Section titled “5. Array(Tupleキャリア)”Type::Tupleはshape_dispatch.rbのTUPLE_HANDLERSとexpression_typer.rbのPER_ELEMENT_TUPLE_METHODSで処理。
5-1. メソッド一覧
Section titled “5-1. メソッド一覧”| メソッド | 状態 | 備考 |
|---|---|---|
[] / fetch | ✅ | tuple_lookup / tuple_fetch — 整数インデックスで位置別型を返す。 |
+(連結) | ✅ | Tuple + Tuple → 新しいTuple。高優先度。tuple_concat実装。 |
-(差集合) | 🔲 | 差集合 → 型が複雑。低優先度。 |
*(繰り返し) | 🔲 | Tuple * n → 繰り返しTuple。低優先度。 |
<< / push / append | 🚫 | 破壊的変更(形状変化)。 |
<=> | 🔷 | RBS Integer?で十分。 |
all? | ✅ | tuple_all? — ブロックなしで要素型確認。BlockFoldingでブロックあり対応。 |
any? | ✅ | tuple_any? — ブロックなしで要素型確認。 |
assoc | 🔲 | 先頭要素マッチ。低優先度。 |
bsearch | 🚫 | 複雑な二分探索。 |
chain | 🚫 | Enumerator。 |
chunk / chunk_while | 🚫 | Enumerable。 |
collect / map | ✅ | PER_ELEMENT_TUPLE_METHODS — ブロック毎要素適用で新Tuple。 |
combination / permutation | 🚫 | Enumerable。 |
compact | ✅ | Constant[nil]エントリーを除去したTuple。高優先度。tuple_compact実装。 |
count | ✅ | tuple_count — ブロックなしでConstant[Integer]。 |
cycle | 🚫 | Enumerable。 |
deconstruct | 🔲 | パターンマッチ用 — to_aと等価。低優先度。 |
delete / delete_at / delete_if | 🚫 | 破壊的変更。 |
detect / find | ✅ | PER_ELEMENT_TUPLE_METHODS — ブロック毎要素で要素型を返す。 |
dig | ✅ | tuple_dig — 入れ子Tuple / HashShapeを掘る。 |
drop | 🔲 | drop(n) → n要素以降の部分Tuple。中優先度。 |
drop_while | 🔷 | BlockFolding FILTER_KEEP_ON_FALSEY。 |
each / each_with_index / each_with_object | 🚫 | 反復子。 |
empty? | ✅ | tuple_empty? → Constant[bool]。 |
entries | 🔷 | to_aの別名 → RBS経由。 |
fetch | ✅ | tuple_fetch → 位置別型。 |
fill | 🚫 | 破壊的変更。 |
filter / select | 🔷 | BlockFolding FILTER_KEEP_ON_TRUTHY / FALSEY。 |
filter_map | ✅ | PER_ELEMENT_TUPLE_METHODS → nil除去後のUnion Tuple。 |
first | ✅ | tuple_first → 先頭n要素(Tupleまたは単一型)。 |
flat_map / collect_concat | ✅ | PER_ELEMENT_TUPLE_METHODS — 単一ネスト除去。 |
flatten | 🔲 | 入れ子Tupleを再帰展開。中優先度。 |
include? | ✅ | tuple_include? → Constant[bool](Constant引数のとき)。 |
index / find_index | ✅ | PER_ELEMENT_TUPLE_METHODS → `Constant[Integer |
insert | 🚫 | 破壊的変更。 |
intersection | 🔲 | 集合交差。低優先度。 |
join | 🔲 | Tuple要素をStringに連結。中優先度(すべてConstantのときConstant[String])。 |
keep_if | 🚫 | 破壊的変更。 |
last | ✅ | tuple_last → 末尾n要素。 |
length / size | ✅ | tuple_size → Constant[Integer]。 |
max / min | ✅ | tuple_max / tuple_min → 要素型のUnion。 |
max_by / min_by | 🔲 | ブロックあり形式。BlockFolding非対応。中優先度。 |
minmax | 🔲 | Tuple[min, max]形式。中優先度。 |
none? | ✅ | tuple_none? → Constant[bool]。 |
pack | 🔲 | バイナリパッキング → Constant[String]。低優先度。 |
pop / shift | 🚫 | 破壊的変更。 |
product | 🚫 | 複雑な直積Tuple。 |
push / unshift | 🚫 | 破壊的変更。 |
rassoc | 🔲 | 低優先度。 |
reject | 🔷 | BlockFolding FILTER_KEEP_ON_FALSEY。 |
repeated_combination / repeated_permutation | 🚫 | Enumerable。 |
reverse | ✅ | tuple_reverse → 要素逆順のTuple。 |
reverse! | 🚫 | 破壊的変更。 |
rotate | 🔲 | rotate(n) → 回転後のTuple。中優先度。 |
sample / shuffle | 🚫 | 非決定論的。 |
slice | 🔲 | values_atと類似。専用ハンドラ。中優先度。 |
sort | ✅ | tuple_sort → 要素型でソートしたTuple。 |
sort! | 🚫 | 破壊的変更。 |
sort_by | 🔲 | ブロックあり。低優先度。 |
sum | ✅ | tuple_sum → 要素型のUnion。 |
take | ✅ | take(n) → 先頭n要素の部分Tuple。高優先度。tuple_take実装。 |
take_while | 🔷 | BlockFolding FILTER_KEEP_ON_TRUTHY。 |
tally | 🔲 | Hash[elem_type, Integer]。低優先度。 |
to_a | ✅ | tuple_to_a → self。 |
to_h | ✅ | tuple_to_h → HashShape(Tuple[Tuple[K,V]…]形式)。 |
transpose | 🔲 | 2次元Tupleの行列転置。低優先度。 |
union | 🔲 | 集合和(dedup)。低優先度。 |
uniq | 🔲 | Tuple要素の重複除去。低優先度。 |
values_at | ✅ | values_at(*indices) → 位置指定Tuple。高優先度。tuple_values_at実装。 |
zip | ✅ | tuple_zip → 要素ペアTuple。 |
5-2. 実装チェックリスト(優先度順)
Section titled “5-2. 実装チェックリスト(優先度順)”高優先度:[x] values_at(*indices) → TUPLE_HANDLERS → Tuple[T[i1], T[i2], …][x] + (Tuple + Tuple) → TUPLE_HANDLERS → 連結 Tuple[x] compact → TUPLE_HANDLERS → nil エントリ除去 Tuple[x] take(n) → TUPLE_HANDLERS → 先頭 n 要素 Tuple
中優先度:[ ] drop(n) → TUPLE_HANDLERS → n 以降の部分 Tuple[ ] rotate(n) → TUPLE_HANDLERS → 回転後 Tuple[ ] flatten → TUPLE_HANDLERS → 1 段ネスト展開(depth=1 限定で実用十分)[ ] join → TUPLE_HANDLERS → すべて Constant のとき Constant[String][ ] slice → TUPLE_HANDLERS → values_at の Range / 2 引数形式
低優先度:[ ] uniq → TUPLE_HANDLERS → Union 縮小 Tuple[ ] minmax → TUPLE_HANDLERS → Tuple[min_type, max_type][ ] max_by / min_by → ExpressionTyper ブロックフォールド追加実装ファイル:
- TUPLE_HANDLERSへの追加:
lib/rigor/inference/method_dispatcher/shape_dispatch.rb - ブロック系追加:
lib/rigor/inference/expression_typer.rb(PER_ELEMENT_TUPLE_METHODS)
6. Set
Section titled “6. Set”現状、SetはNominal[Set]としてRBSから型を取得。SetShapeキャリアは存在しない。
6-1. 状況整理
Section titled “6-1. 状況整理”| 観点 | 内容 |
|---|---|
| 現在の精度 | RBS Set[T]経由。include?はbool返却(Constant[bool]にならない)。 |
| SetShapeがない理由 | Setのリテラル構文がRubyにない(Set[1, 2, 3]はSet.new呼び出し)ため形状を静的に確定しにくい。 |
| 精度向上できる範囲 | SetのSIZE_RETURNING_NOMINALSへの登録でsize/length/countがIntegerRangeを返す(ShapeDispatch側)。それ以上はSetShapeなしでは難しい。 |
6-2. 実装チェックリスト
Section titled “6-2. 実装チェックリスト”現時点で対応可能(SetShape 不要):[ ] size / length / count → SIZE_RETURNING_NOMINALS に Set が登録済か確認 (登録済みであれば ✅ — shape_dispatch.rb の SIZE_RETURNING_NOMINALS を参照)
将来的な SetShape 導入時に対応:[ ] include? / member? → Constant[bool][ ] empty? → Constant[bool][ ] subset? / superset? → Constant[bool][ ] + / | / & / - → 新 Set 型SetShape導入は現サイクルでは対象外。需要が出た時点でADR化を検討。
優先度サマリー
Section titled “優先度サマリー”2026-05-22時点の高優先度タスクは全件実装済み。
| 型 | 状態 | 実装(2026-05-22) |
|---|---|---|
| String | ✅ | start_with? / end_with? / include? / delete_prefix / delete_suffix → STRING_BINARY |
| String | ✅ | to_i / to_f / ord → STRING_UNARY |
| Integer | ✅ | ** / & / ` |
| Float | ✅ | ** → NUMERIC_BINARY |
| Array / Tuple | ✅ | values_at / + / compact / take → TUPLE_HANDLERS |
| bool | ✅ | === → BOOL_BINARY |
| Set | — | SetShape不要で対応できる項目なし(size確認程度) |
© 2026 TypedDuck. Licensed under CC BY-SA 4.0.