potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
606 stars 81 forks source link

Cannot instantiate Comment AST using CommentType enum as argument. #506

Closed namcsi closed 3 months ago

namcsi commented 3 months ago

As title says, I've ran into an issue instantiating the Comment AST:

from clingo.ast import Location, Position, Comment, CommentType
loc = Location(Position("<string>", 1, 1), Position("<string>", 1, 1))
block_type = CommentType.Block
Comment(loc, "% comment", block_type)

The final line throws:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/home/amicsi/ghq/github.com/krr-up/renopro/.nox/dev/lib64/python3.12/site-packages/clingo/ast.py", line 2390, in Comment
    _ffi.cast("int", block_type),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: an integer is required

I believe this is due to CommentType being defined as an OrderedEnum instead of IntEnum, like the rest of the AST argument enums.