Skip to content

Commit 8e0c3de

Browse files
committed
refactor: Simplify main module name assignment
1 parent 4eb1a63 commit 8e0c3de

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

quint/src/cliCommands.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ export async function runRepl(_argv: any) {
322322
export async function runTests(prev: TypecheckedStage): Promise<CLIProcedure<TestedStage>> {
323323
const testing = { ...prev, stage: 'testing' as stage }
324324
const verbosityLevel = deriveVerbosity(prev.args)
325-
const guessedMainModule = guessMainModule(prev)
326-
const mainName = prev.args.main || guessedMainModule
325+
const mainName = guessMainModule(prev)
327326
const main = prev.modules.find(m => m.name === mainName)
328327
if (!main) {
329328
const error: QuintError = { code: 'QNT405', message: `Main module ${mainName} not found` }
@@ -521,8 +520,7 @@ export async function runSimulator(prev: TypecheckedStage): Promise<CLIProcedure
521520
const startMs = Date.now()
522521
// Force disable output if `--out-itf` is set
523522
const verbosityLevel = prev.args.outItf ? 0 : deriveVerbosity(prev.args)
524-
const guessedMainModule = guessMainModule(prev)
525-
const mainName = prev.args.main || guessedMainModule
523+
const mainName = guessMainModule(prev)
526524
const main = prev.modules.find(m => m.name === mainName)
527525
if (!main) {
528526
const error: QuintError = { code: 'QNT405', message: `Main module ${mainName} not found` }
@@ -544,18 +542,18 @@ export async function runSimulator(prev: TypecheckedStage): Promise<CLIProcedure
544542
invariantsList = invariantsList.concat(prev.args.invariants)
545543
}
546544
// If no invariants specified, use the default 'true'
547-
const invariant = invariantsList.length > 0 ? invariantsList.join(' and ') : 'true'
545+
const invariantString = invariantsList.length > 0 ? invariantsList.join(' and ') : 'true'
548546
// Keep track of individual invariants for reporting
549547
const individualInvariants = invariantsList.length > 0 ? invariantsList : ['true']
550548

551549
// We use:
552-
// - 'invariant' as the combined invariant string for the simulator to check
550+
// - 'invariantString' as the combined invariant string for the simulator to check
553551
// - 'individualInvariants' for reporting which specific invariants were violated
554552

555553
const options: SimulatorOptions = {
556554
init: prev.args.init,
557555
step: prev.args.step,
558-
invariant: invariant,
556+
invariant: invariantString,
559557
individualInvariants: individualInvariants,
560558
maxSamples: prev.args.maxSamples,
561559
maxSteps: prev.args.maxSteps,
@@ -597,7 +595,7 @@ export async function runSimulator(prev: TypecheckedStage): Promise<CLIProcedure
597595
}
598596

599597
const argsParsingResult = mergeInMany(
600-
[prev.args.init, prev.args.step, invariant, ...prev.args.witnesses].map(toExpr)
598+
[prev.args.init, prev.args.step, invariantString, ...prev.args.witnesses].map(toExpr)
601599
)
602600
if (argsParsingResult.isLeft()) {
603601
return cliErr('Argument error', {
@@ -617,7 +615,7 @@ export async function runSimulator(prev: TypecheckedStage): Promise<CLIProcedure
617615
}
618616

619617
// Parse the combined invariant for the Rust backend
620-
const invariantExpr = toExpr(invariant)
618+
const invariantExpr = toExpr(invariantString)
621619
if (invariantExpr.isLeft()) {
622620
return cliErr('Argument error', {
623621
...simulator,
@@ -782,10 +780,10 @@ export async function compile(typechecked: TypecheckedStage): Promise<CLIProcedu
782780
invariantsList = invariantsList.concat(args.invariants)
783781
}
784782
// If no invariants specified, use the default 'true'
785-
const invariant = invariantsList.length > 0 ? invariantsList.join(' and ') : 'true'
783+
const invariantString = invariantsList.length > 0 ? invariantsList.join(' and ') : 'true'
786784

787785
const extraDefsAsText = [`action q::init = ${args.init}`, `action q::step = ${args.step}`]
788-
extraDefsAsText.push(`val q::inv = and(${invariant})`)
786+
extraDefsAsText.push(`val q::inv = and(${invariantString})`)
789787

790788
if (args.temporal) {
791789
extraDefsAsText.push(`temporal q::temporalProps = and(${args.temporal})`)

0 commit comments

Comments
 (0)