Skip to content

Commit 138892f

Browse files
committed
fix: wrap ISC alias definitions in AliasDef; harden the normalizer on raw leaves
Two more ISC-only breaks, both invisible on .imp installs: - NodeAdapter stored alias values as bare items. The interpreter resolves aliases through AliasDef#data and feeds it to Item.try_convert — a bare Any hands it Any#data, an Array, and every library-dependent map dies with 'Wrong type Array' the moment locate() resolves a library to libs/*.isc instead of a legacy .iml. - Normalizer#normalize_meta_field assumed Hash entries; empty metadata blocks carry a bare Parslet::Slice. scalar() also learns the {raw: } string form the grammar emits for some metadata fields.
1 parent ddc05c0 commit 138892f

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎lib/interscript/isc/node_adapter.rb‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ def build_tests
5555

5656
def build_aliases
5757
@isc_doc[:aliases].each_with_object({}) do |a, h|
58-
h[a[:name].to_sym] = convert_item(a[:value])
58+
# The runtime resolves aliases through AliasDef#data (see
59+
# Interpreter::Stage#build_item); a bare item here hands it a
60+
# raw Array once Any#data unrolls.
61+
h[a[:name].to_sym] = Interscript::Node::AliasDef.new(a[:name].to_sym, convert_item(a[:value]))
5962
end
6063
end
6164

‎lib/interscript/isc/normalizer.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ def scalar(node)
4242
Array(node[:string]).map { |part| part.is_a?(Hash) ? part[:char].to_s : part.to_s }.join
4343
elsif node.key?(:identifier)
4444
node[:identifier].to_s
45+
elsif node.key?(:raw)
46+
node[:raw].to_s
4547
else
4648
node
4749
end
@@ -71,7 +73,7 @@ def normalize_block(block)
7173
# {field_name: {identifier: "authority"}, field_value: {string: [...]}}
7274
# becomes {authority: "BGN-PCGN"}.
7375
def normalize_meta_field(field)
74-
return field unless field.key?(:field_name)
76+
return field unless field.is_a?(Hash) && field.key?(:field_name)
7577

7678
name = scalar(field[:field_name]).to_sym
7779
value = field.key?(:field_block) ? field[:field_block] : scalar(field[:field_value])

0 commit comments

Comments
 (0)