Skip to content

Commit 8d8510b

Browse files
committed
fix: library dependencies cannot be hijacked by same-name maps
A library dependency (posix, unicode) contributes aliases through the .iml harvest. When a load path also holds an emitted map of the same name — the Ruby bridge writes generated unicode.isc next to the maps it serves — the map-import branch shadowed the library and its plain-string aliases rendered as literal sequences instead of classes: alalc-ell's any(greek) guards compiled to the literal 300-character alphabet and gamma nasalization never fired. Library names now claim their dependency slot when the .iml exists; an imported alias resolving to a plain string inside any() also compiles as a class (the qualified 404 pins stay literal — bare references are untouched).
1 parent 100c17c commit 8d8510b

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

‎src/interscript/isc.py‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -673,15 +673,21 @@ def _render_item(item: dict, aliases: dict[str, str]) -> str:
673673
return f'any("{_escape("".join(sub["value"] for sub in items))}")'
674674
# any(<single alias resolving to a plain string>) is a character
675675
# class (measured against Ruby: the unicode library's greek);
676-
# a bare alias reference stays a literal sequence.
676+
# a bare alias reference stays a literal sequence. Imported
677+
# aliases resolve through the qualified path.
677678
if (
678679
len(items) == 1
679680
and items[0]["type"] == "alias_ref"
680681
and not items[0].get("map")
681-
and items[0]["name"] in aliases
682682
):
683-
resolved = aliases[items[0]["name"]]
684-
if is_plain_string(resolved):
683+
name = items[0]["name"]
684+
if name in aliases:
685+
resolved = aliases[name]
686+
elif name in _imported:
687+
resolved = _qualified_expr(None, name)
688+
else:
689+
resolved = None
690+
if resolved is not None and is_plain_string(resolved):
685691
return f"any({resolved})"
686692
return "any([" + ", ".join(_render_item(sub, aliases) for sub in items) + "])"
687693
if kind == "range":
@@ -1054,8 +1060,11 @@ def isc_to_tree(source: str, filename: str | None = None, on_unsupported: str =
10541060
# this map's scope; system dependencies do not.
10551061
libs_dir = Path(filename).parent.parent / "libs" if filename else Path("libs")
10561062
library_aliases: dict[str, str] = {}
1063+
lib_names: set[str] = set()
10571064
for dep in doc["dependencies"]:
10581065
if "/" not in dep["target"] and "." not in dep["target"]:
1066+
if (libs_dir / f"{dep['target']}.iml").is_file():
1067+
lib_names.add(dep["target"])
10591068
library_aliases.update(_library_aliases(dep["target"], libs_dir))
10601069

10611070
aliases: dict[str, str] = dict(library_aliases)
@@ -1082,6 +1091,11 @@ def isc_to_tree(source: str, filename: str | None = None, on_unsupported: str =
10821091
for d in doc["dependencies"]:
10831092
if d.get("aliasName"):
10841093
continue
1094+
if d["target"] in lib_names:
1095+
# A library dependency (posix, unicode) contributes through
1096+
# the harvest above; an emitted map of the same name in a
1097+
# load path must not hijack it into the map-import path.
1098+
continue
10851099
from .interscript import _find_map
10861100

10871101
if _find_map(d["target"]) is not None:

0 commit comments

Comments
 (0)