Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Lean/Shell.lean
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ def ShellOptions.process (opts : ShellOptions)
let arg ← checkOptArg "j" optArg?
let some numThreads := arg.toNat?
| throwExpectedNumeric "j"
if numThreads == 0 then
throwExpectedPositive "j"
if h : numThreads < UInt32.size then
let numThreads := UInt32.ofNatLT numThreads h
let forwardedArgs := opts.forwardedArgs.push s!"-j{arg}";
Expand Down Expand Up @@ -460,6 +462,9 @@ where
@[inline] throwExpectedNumeric opt := do
eprint s!"error: expected numeric argument for option '-{opt}'\n"
throw 1
@[inline] throwExpectedPositive opt := do
eprint s!"error: expected positive numeric argument for option '-{opt}'\n"
throw 1
@[inline] throwTooLarge opt := do
eprint s!"error: argument value for '-{opt}' is too large\n"
throw 1
Expand Down
11 changes: 11 additions & 0 deletions tests/misc/threads_zero.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set -euo pipefail

out="${NAME}.out"
trap 'rm -f "$out"' EXIT

if lean -j0 >"$out" 2>&1; then
echo "lean -j0 unexpectedly succeeded" >&2
exit 1
fi

grep -Fx "error: expected positive numeric argument for option '-j'" "$out"
Loading