Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lark.grammar.Symbol.__eq__ raises an AssertionError when checking if None == Symbol(...) #1476

Open
weaversam8 opened this issue Oct 15, 2024 · 1 comment

Comments

@weaversam8
Copy link

Describe the bug

When attempting to compare a variable set to None with a Symbol, Lark's implementation of __eq__ within the Symbol class raises an AssertionError.

To Reproduce

from lark.grammar import Symbol
a = None
b = Symbol("abc")

# this throws an error:
a == b

The error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[...]/venv/lib/python3.8/site-packages/lark/grammar.py", line 19, in __eq__
    assert isinstance(other, Symbol), other
AssertionError: None
@erezsh
Copy link
Member

erezsh commented Oct 16, 2024

This class is mainly for internal use, but I will accept a PR that returns False if the other object is None.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants