Repository navigation
fix: more cli argument validation, cli's defaults compatibility, implied arguments - #95
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ondrik
force-pushed
the
fix/85-cli-errors
branch
from
October 27, 2026 13:15
e6f68d5 to
45210c4
Compare
The reference documents the simulator's -T as at least 1, as for milq, but it accepted 0, which then failed in simulate_rus with exit status 1 instead of a usage error (2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0177AhE9SXm3iJ1KP8GTSk6o
ondrik
force-pushed
the
fix/85-cli-errors
branch
from
October 27, 2026 13:45
45210c4 to
7c822d5
Compare
ondrik
approved these changes
Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #85.
Exit status (F39)
milqnow exits non-zero when synthesis fails:0123--max-depth/-ptsynthesis failedand errors go to stderr. The exit codes are documented indocs/reference.md.Option defaults and errors (F40)
-adefaults to the backend's solver:yices2for-s smt,cbcfor-s milp,gurobifor-s gurobi.milq x.qasm -s smtnow works. A solver that doesn't fit the backend (e.g.-s smt -a cbc) is a usage error that lists the valid choices.ValueError,OSError,RuntimeError,SolverErrorandGurobiErrorare caught and printed asmilq: error: ...instead of a traceback.-d≥ 0,--max-depth≥ 1,-T≥ 1,-A≥ 0,-fin [0, 1],-pt> 0.synthesis()also rejects a negatived.-fhelp text (it is for-ap, not dreal).Options outside their mode (F79 and similar)
These options used to be accepted and silently ignored. They are now rejected outside the mode they apply to:
-d: only basic/binary/topdown/bottomup (the message points to--max-depth)--max-depth: only incremental/pareto-incremental (the message points to-d)-f: only with-ap-pt: only with-m pareto-incremental-T,-A: only with-v rus-dstays separate from--max-depth. In the incremental modesdsizes the encoding (preallocated layers, value bounds,max_k) and is not a limit, so each CLI flag still maps to exactly onesynthesis()argument.cli/simulator.pysimulator: error: ...instead of tracebacks,-mlimited to0/1,-T/-Achecked and only with-v rus, works through a symlink (realpath), corrected help text, unused imports removed.Exception. It now raisesValueErrorand names the line.-v ruswith no targets, or with fewer targets + ancillas than the circuit's qubits, crashed withIndexError. It now raises aValueErrorthat explains why.Behaviour changes
-d,--max-depth,-f,-pt,-Tor-Awhere they had no effect now stop with exit 2. Results of valid commands are unchanged.Tests
tests/test_cli.pyruns both scripts and checks the exit codes and that no traceback is printed.sim.pyerrors and for a negatived.