diff --git a/jaclang/compiler/passes/main/access_modifier_pass.py b/jaclang/compiler/passes/main/access_modifier_pass.py index 0fc375edb..7e897865b 100644 --- a/jaclang/compiler/passes/main/access_modifier_pass.py +++ b/jaclang/compiler/passes/main/access_modifier_pass.py @@ -205,26 +205,26 @@ def enter_name(self, node: ast.Name) -> None: # Accessing a private/protected member within the top level scope illegal. if curr_class is None: return self.report_error( - f"Error: Invalid access of {access_type} member.", + f'Error: Invalid access of {access_type} member "{node.sym_name}".', node, ) if curr_class != node.sym.parent_tab.owner: if not is_portect: # private member accessed in a different class. return self.report_error( - f"Error: Invalid access of {access_type} member.", + f'Error: Invalid access of {access_type} member "{node.sym_name}".', node, ) else: # Accessing a protected member, check we're in an inherited class. if not self.is_class_inherited_from(curr_class, sym_owner): return self.report_error( - f"Error: Invalid access of {access_type} member.", + f'Error: Invalid access of {access_type} member "{node.sym_name}".', node, ) elif isinstance(sym_owner, ast.Module) and sym_owner != curr_module: # Accessing a private/public member in a different module. return self.report_error( - f"Error: Invalid access of {access_type} member.", + f'Error: Invalid access of {access_type} member "{node.sym_name}".', node, ) diff --git a/jaclang/compiler/passes/main/fuse_typeinfo_pass.py b/jaclang/compiler/passes/main/fuse_typeinfo_pass.py index 3c2e8cab8..dc9e4c381 100644 --- a/jaclang/compiler/passes/main/fuse_typeinfo_pass.py +++ b/jaclang/compiler/passes/main/fuse_typeinfo_pass.py @@ -6,11 +6,10 @@ from __future__ import annotations -from typing import Callable, Optional, TypeVar +from typing import Callable, TypeVar import jaclang.compiler.absyntree as ast from jaclang.compiler.passes import Pass -from jaclang.compiler.symtable import Symbol from jaclang.settings import settings from jaclang.utils.helpers import pascal_to_snake from jaclang.vendor.mypy.nodes import Node as VNode # bit of a hack @@ -494,28 +493,29 @@ def exit_atom_trailer(self, node: ast.AtomTrailer) -> None: ): # TODO check why IndexSlice produce an issue right.name_spec.sym = left.type_sym_tab.lookup(right.sym_name) - # NOTE: Note sure why we're inferring the symbol here instead of the sym table build pass - # I afraid that moving this there might break something. - def lookup_sym_from_node(self, node: ast.AstNode, member: str) -> Optional[Symbol]: - """Recursively look for the symbol of a member from a given node.""" - if isinstance(node, ast.AstSymbolNode): - if node.type_sym_tab is None: - return None - return node.type_sym_tab.lookup(member) - - if isinstance(node, ast.AtomTrailer): - if node.is_attr: # .member access. - return self.lookup_sym_from_node(node.right, member) - elif isinstance(node.right, ast.IndexSlice): - # NOTE: if the 'node.target' is a variable of type list[T] the - # node.target.sym_type is "builtins.list[T]" string Not sure how - # to get the type_sym_tab of "T" from just the name itself. would - # be better if the symbols types are not just strings but references. - # For now I'll mark them as todos. - # TODO: - # case 1: expr[i] -> regular indexing. - # case 2: expr[i:j:k] -> returns a sublist. - # case 3: expr["str"] -> dictionary lookup. - pass - - return None + # # TODO [Gamal]: Need to support getting the type of an expression + # # NOTE: Note sure why we're inferring the symbol here instead of the sym table build pass + # # I afraid that moving this there might break something. + # def lookup_sym_from_node(self, node: ast.AstNode, member: str) -> Optional[Symbol]: + # """Recursively look for the symbol of a member from a given node.""" + # if isinstance(node, ast.AstSymbolNode): + # if node.type_sym_tab is None: + # return None + # return node.type_sym_tab.lookup(member) + + # if isinstance(node, ast.AtomTrailer): + # if node.is_attr: # .member access. + # return self.lookup_sym_from_node(node.right, member) + # elif isinstance(node.right, ast.IndexSlice): + # # NOTE: if the 'node.target' is a variable of type list[T] the + # # node.target.sym_type is "builtins.list[T]" string Not sure how + # # to get the type_sym_tab of "T" from just the name itself. would + # # be better if the symbols types are not just strings but references. + # # For now I'll mark them as todos. + # # TODO: + # # case 1: expr[i] -> regular indexing. + # # case 2: expr[i:j:k] -> returns a sublist. + # # case 3: expr["str"] -> dictionary lookup. + # pass + + # return None