Skip to content

Commit a7d8ca7

Browse files
committed
refactor: Simplify main module name assignment
1 parent 9821025 commit a7d8ca7

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` }
@@ -518,8 +517,7 @@ export async function runSimulator(prev: TypecheckedStage): Promise<CLIProcedure
518517
const startMs = Date.now()
519518
// Force disable output if `--out-itf` is set
520519
const verbosityLevel = prev.args.outItf ? 0 : deriveVerbosity(prev.args)
521-
const guessedMainModule = guessMainModule(prev)
522-
const mainName = prev.args.main || guessedMainModule
520+
const mainName = guessMainModule(prev)
523521
const main = prev.modules.find(m => m.name === mainName)
524522
if (!main) {
525523
const error: QuintError = { code: 'QNT405', message: `Main module ${mainName} not found` }
@@ -541,18 +539,18 @@ export async function runSimulator(prev: TypecheckedStage): Promise<CLIProcedure
541539
invariantsList = invariantsList.concat(prev.args.invariants)
542540
}
543541
// If no invariants specified, use the default 'true'
544-
const invariant = invariantsList.length > 0 ? invariantsList.join(' and ') : 'true'
542+
const invariantString = invariantsList.length > 0 ? invariantsList.join(' and ') : 'true'
545543
// Keep track of individual invariants for reporting
546544
const individualInvariants = invariantsList.length > 0 ? invariantsList : ['true']
547545

548546
// We use:
549-
// - 'invariant' as the combined invariant string for the simulator to check
547+
// - 'invariantString' as the combined invariant string for the simulator to check
550548
// - 'individualInvariants' for reporting which specific invariants were violated
551549

552550
const options: SimulatorOptions = {
553551
init: prev.args.init,
554552
step: prev.args.step,
555-
invariant: invariant,
553+
invariant: invariantString,
556554
individualInvariants: individualInvariants,
557555
maxSamples: prev.args.maxSamples,
558556
maxSteps: prev.args.maxSteps,
@@ -594,7 +592,7 @@ export async function runSimulator(prev: TypecheckedStage): Promise<CLIProcedure
594592
}
595593

596594
const argsParsingResult = mergeInMany(
597-
[prev.args.init, prev.args.step, invariant, ...prev.args.witnesses].map(toExpr)
595+
[prev.args.init, prev.args.step, invariantString, ...prev.args.witnesses].map(toExpr)
598596
)
599597
if (argsParsingResult.isLeft()) {
600598
return cliErr('Argument error', {
@@ -614,7 +612,7 @@ export async function runSimulator(prev: TypecheckedStage): Promise<CLIProcedure
614612
}
615613

616614
// Parse the combined invariant for the Rust backend
617-
const invariantExpr = toExpr(invariant)
615+
const invariantExpr = toExpr(invariantString)
618616
if (invariantExpr.isLeft()) {
619617
return cliErr('Argument error', {
620618
...simulator,
@@ -779,10 +777,10 @@ export async function compile(typechecked: TypecheckedStage): Promise<CLIProcedu
779777
invariantsList = invariantsList.concat(args.invariants)
780778
}
781779
// If no invariants specified, use the default 'true'
782-
const invariant = invariantsList.length > 0 ? invariantsList.join(' and ') : 'true'
780+
const invariantString = invariantsList.length > 0 ? invariantsList.join(' and ') : 'true'
783781

784782
const extraDefsAsText = [`action q::init = ${args.init}`, `action q::step = ${args.step}`]
785-
extraDefsAsText.push(`val q::inv = and(${invariant})`)
783+
extraDefsAsText.push(`val q::inv = and(${invariantString})`)
786784

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

0 commit comments

Comments
 (0)