Skip to content

[Bug]: A multi-line constructor in a .qp file fails as a bare ValueError #37

Description

@fedonman

Bug Description

A constructor split across two lines in a .qp file fails as a bare ValueError: substring not found, with no line number and outside the QProgramError hierarchy. The cause is an unguarded rindex(")") in the parser's argument slicing. The .wfl reader hits the identical failure and wraps it into a line-tagged ParseError, so the two formats report the same mistake very differently.

Minimal Reproducible Example

import qprogram as qp

qp.loads(
    '#!QProgram 1.0\n'
    '\n'
    'body:\n'
    '  play "d" Gaussian(amplitude=0.5,\n'
    '    duration=40, sigma=8)\n'
)

Expected Behavior

A ParseError carrying the line number, the way the .wfl reader already reports it: Line 2: invalid waveform: substring not found. Multi-line constructors are not supported (.qp has no line continuation), but the refusal should be diagnosable.

Actual Behavior

ValueError: substring not found

.qp Text

#!QProgram 1.0

body:
  play "d" Gaussian(amplitude=0.5,
    duration=40, sigma=8)

System Information

qprogram 0.1.0
python   3.14.7 | Linux-6.18.33.2-microsoft-standard-WSL2-x86_64-with-glibc2.43
vendors  none

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    serializationTouches the .qp writer, parser, registry and grammar

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions