Skip to content

Dynamic RepetitionBoundsConstraint does not work with generators #742

@henryhchchc

Description

@henryhchchc

With the following spec in test.fan:

<start> ::= <len> <cnt>
<len> ::= <digit>{2}
<cnt> ::= <byte>{calc_len(<len>)} := gen_cnt(<len>)

def calc_len(len_nt):
  return int(bytes(len_nt).decode())

def gen_cnt(len_nt):
  import random
  length = calc_len(len_nt)
  return random.randbytes(length)

fandango fuzz -f test.fan errored

<root>/src/fandango/language/search.py:236: UserWarning: Don't rely on the __str__ impl on RuleSearch, use method specific to your usecase. Report this as a bug if this is called from within Fandango.
  warnings.warn(
FandangoParseError: Could not parse b'\xc7\x83g<l\xe9\x02\xc6\xc82\xdb\xc9u\xac\xe8' (generated by gen_cnt(...)) into <cnt>

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions