diff --git a/lib/core/Handles/HandlesBase.py b/lib/core/Handles/HandlesBase.py index a3baa1e..327a4df 100644 --- a/lib/core/Handles/HandlesBase.py +++ b/lib/core/Handles/HandlesBase.py @@ -783,6 +783,34 @@ class BaseHandle: # 见 HandlesExprCall._RequireArgValue)。 if isinstance(Node, ast.Attribute): msg += "\n│ 基址诊断: " + self._DescribeAttrBase(Gen, Node) + elif isinstance(Node, ast.Call) and isinstance(Node.func, ast.Attribute): + # 被调者形如 `接收者链.方法(...)`:整条 Call 求值为空的**唯一来源**是接收者链 + # 先求值为空(HandlesExprCall._HandleMethodCallLlvm 里 + # `ObjVal = HandleExprLlvm(Node.func.value)` 为假即 `return None`; + # 方法声明缺失会在同函数内 raise "Undefined method …",不会走到这里)。 + # 行号只能指到整条调用,故把**接收者**的基址事实与最近一次属性读取失败原因 + # 一并回显;Call 形态下无法用 (类, 字段) 与节点比对,该记录无条件回显。 + try: + msg += "\n│ 被调者接收者诊断: " + self._DescribeAttrBase(Gen, Node.func.value) + except Exception as _e_d: # noqa: BLE001 + msg += f"\n│ 被调者接收者诊断生成失败: {type(_e_d).__name__}: {_e_d}" + try: + _recC: Any = getattr(Gen, '_LastAttrNone', None) + if isinstance(_recC, tuple) and len(_recC) >= 3 and _recC[2]: + msg += (f"\n│ 最近一次属性读取失败: 类={_recC[0]!r} 字段={_recC[1]!r}" + f" 原因={_recC[2]}") + except Exception: # noqa: BLE001 + pass + _mnC: str = getattr(Node.func, 'attr', '') or '' + _declC: list[str] = [] + try: + for _fk in (getattr(Gen, 'functions', {}) or {}): + if _mnC and _fk.endswith(f'.{_mnC}'): + _declC.append(_fk) + except Exception: # noqa: BLE001 + _declC = [] + msg += (f"\n│ 被调方法={_mnC!r};已声明同名方法键(示前 4 / 共 {len(_declC)}): " + f"{_declC[:4]}") _vlog().compile_error(msg, src_file, lineno, code_line) sys.exit(1)