From 4e62908a1757f83ff703399252ad50758c4eb237 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 24 Feb 2026 17:18:29 +0100 Subject: Replace silent rescue with explicit type check in Item constructor When creating an Item from a Rule (not an Item), tail_spans doesn't exist. Check with is_a?(Item) instead of catching the exception silently. Co-Authored-By: Claude Opus 4.6 --- prototype/parse.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'prototype/parse.rb') diff --git a/prototype/parse.rb b/prototype/parse.rb index adf2b91..40a69e7 100644 --- a/prototype/parse.rb +++ b/prototype/parse.rb @@ -90,14 +90,10 @@ class Item < Grammar::Rule rule_or_item.rhs.each_with_index { |x,i| # duplicate rhs partially @rhs << x if x.class == Grammar::NT - begin - if i >= dot - @tail_spans[i] = Span.new(-1, -1) - else - @tail_spans[i] = rule_or_item.tail_spans[i].dup - end - rescue + if i >= dot || !rule_or_item.is_a?(Item) @tail_spans[i] = Span.new(-1, -1) + else + @tail_spans[i] = rule_or_item.tail_spans[i].dup end end } -- cgit v1.2.3