Skip to content

Commit 713aa03

Browse files
Merge ab93b8a into 5594178
2 parents 5594178 + ab93b8a commit 713aa03

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/Lean/Shell.lean

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ def ShellOptions.process (opts : ShellOptions)
301301
let arg ← checkOptArg "j" optArg?
302302
let some numThreads := arg.toNat?
303303
| throwExpectedNumeric "j"
304+
if numThreads == 0 then
305+
throwExpectedPositive "j"
304306
if h : numThreads < UInt32.size then
305307
let numThreads := UInt32.ofNatLT numThreads h
306308
let forwardedArgs := opts.forwardedArgs.push s!"-j{arg}";
@@ -460,6 +462,9 @@ where
460462
@[inline] throwExpectedNumeric opt := do
461463
eprint s!"error: expected numeric argument for option '-{opt}'\n"
462464
throw 1
465+
@[inline] throwExpectedPositive opt := do
466+
eprint s!"error: expected positive numeric argument for option '-{opt}'\n"
467+
throw 1
463468
@[inline] throwTooLarge opt := do
464469
eprint s!"error: argument value for '-{opt}' is too large\n"
465470
throw 1

tests/misc/threads_zero.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set -euo pipefail
2+
3+
out="${NAME}.out"
4+
trap 'rm -f "$out"' EXIT
5+
6+
if lean -j0 >"$out" 2>&1; then
7+
echo "lean -j0 unexpectedly succeeded" >&2
8+
exit 1
9+
fi
10+
11+
grep -Fx "error: expected positive numeric argument for option '-j'" "$out"

0 commit comments

Comments
 (0)