Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pytest-xdist = "*"
setuptools = ">=70.1.1,<79.0.0"

[build-system]
requires = ["poetry-core>=2.0.0"]
requires = ["poetry-core>=2.4.1"]
build-backend = "poetry.core.masonry.api"

[tool.poe.tasks]
Expand Down
7 changes: 7 additions & 0 deletions src/api/errmsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"register_warning",
"warning",
"warning_not_used",
"warning_uninitalized_string_var",
)


Expand Down Expand Up @@ -127,6 +128,12 @@ def warning_implicit_type(lineno: int, id_: str, type_: str = None):
warning(lineno, "Using default implicit type '%s' for '%s'" % (type_, id_))


@register_warning("101")
def warning_uninitalized_string_var(lineno: int, id_: str):
"""Warning: Accessing uninitialized string variable"""
warning(lineno, f"Accessing uninitialized string variable '{id_}'")


@register_warning("110")
def warning_condition_is_always(lineno: int, cond: bool = False):
"""Warning: Condition is always false/true"""
Expand Down
11 changes: 5 additions & 6 deletions src/api/symboltable/symboltable.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def declare(self, id_: str, lineno: int, entry: symbols.ID | symbols.TYPE) -> No

return entry

def declare_safe(self, id_: str, lineno: int, entry: symbols.ID):
def declare_safe(self, id_: str, lineno: int, entry: symbols.ID) -> symbols.ID | symbols.TYPE:
"""Like declare, but never returns None"""
result = self.declare(id_, lineno, entry)
assert result is not None
Expand Down Expand Up @@ -204,7 +204,7 @@ def check_is_undeclared(
)
return False

def check_class(self, id_: str, class_: CLASS, lineno: int, scope: Scope = None, show_error=True) -> bool:
def check_class(self, id_: str, class_: CLASS, lineno: int, scope: Scope | None = None, show_error=True) -> bool:
"""Check the id is either undefined or defined with
the given class.

Expand Down Expand Up @@ -342,7 +342,7 @@ def access_id(
default_class: CLASS = CLASS.unknown,
*,
ignore_explicit_flag=False,
):
) -> symbols.ID | None:
"""Access a symbol by its identifier and checks if it exists.
If not, it's supposed to be an implicitly declared variable.

Expand Down Expand Up @@ -442,10 +442,9 @@ def access_func(self, id_: str, lineno: int, scope=None, default_type=None):

return result

def access_call(self, id_: str, lineno: int, scope=None, type_=None):
def access_call(self, id_: str, lineno: int, scope=None, type_=None) -> symbols.ID | None:
"""Creates a func/array/string call. Checks if id is callable or not.
An identifier is "callable" if it can be followed by a list of para-
meters.
An identifier is "callable" if it can be followed by a list of parameters.
This does not mean the id_ is a function, but that it allows the same
syntax a function does:

Expand Down
3 changes: 2 additions & 1 deletion src/zxbc/zxbparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,8 @@ def p_substr_assignment_no_let(p):
return

if entry.class_ == CLASS.unknown:
entry.class_ = CLASS.var
errmsg.warning_uninitalized_string_var(p.lineno(1), entry.name)
entry.to_var()

if p[6].type_ != Type.string:
errmsg.syntax_error_expected_string(p.lineno(5), p[6].type_)
Expand Down
Loading
Loading