Skip to content

[Bug]: A .qp file using vendor operations loads without its require line #13

Description

@fedonman

Bug Description

_Parser collects every require line into self._required_vendors and then never reads it, so a file whose body uses dummy.acquire parses fine with no require dummy 0.1 line, as long as something in the process already imported the extension. The format spec says every vendor operation in the body must have a matching require declaration. Whether the file loads therefore depends on ambient import state, and it will fail for the next reader: auto-activation only runs off a require line, so without one the extension is never imported on demand and the same file raises unknown vendor operation dummy.'acquire'. A check of the vendors actually used against _required_vendors after the body is parsed would close it.

Minimal Reproducible Example

import sys; sys.path.insert(0, "tests")
import qprogram as qp
import _dummy_vendor
_dummy_vendor.activate()

qp.loads("""#!QProgram 1.0
body:
  dummy.acquire "readout_q0" "weights" name="m0"
""")

Expected Behavior

ParseError naming the vendor whose require line is missing.

Actual Behavior

No error. The program loads, and `dumps()` then writes the file back with a `require dummy 0.1` line that was never in the input.

.qp Text

#!QProgram 1.0
body:
  dummy.acquire "readout_q0" "weights" name="m0"

System Information

qprogram 0.1.0
python   3.14.3 | Linux-7.0.0-30-generic-x86_64-with-glibc2.43
vendors  none

Metadata

Metadata

Assignees

No one assigned

    Labels

    serializationTouches the .qp writer, parser, registry and grammar

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions