Skip to content

Commit 470ff48

Browse files
authored
REPL: typeassert displaysize return value (#57919)
Improve abstract type inference. This is OK because `displaysize` is documented to always return a `Tuple{Int, Int}` value. Also add a test.
1 parent a5e0eab commit 470ff48

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

stdlib/REPL/src/Terminals.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ end
146146
@eval clear_line(t::UnixTerminal) = write(t.out_stream, $"\r$(CSI)0K")
147147
beep(t::UnixTerminal) = write(t.err_stream,"\x7")
148148

149-
Base.displaysize(t::UnixTerminal) = displaysize(t.out_stream)
149+
Base.displaysize(t::UnixTerminal) = displaysize(t.out_stream)::Tuple{Int,Int}
150150

151151
hascolor(t::TTYTerminal) = get(t.out_stream, :color, false)::Bool
152152

stdlib/REPL/test/repl.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,10 @@ end
19531953
end
19541954
end
19551955

1956+
@testset "`displaysize` return type inference" begin
1957+
@test Tuple{Int, Int} === Base.infer_return_type(displaysize, Tuple{REPL.Terminals.UnixTerminal})
1958+
end
1959+
19561960
@testset "Dummy Pkg prompt" begin
19571961
# do this in an empty depot to test default for new users
19581962
withenv("JULIA_DEPOT_PATH" => mktempdir() * (Sys.iswindows() ? ";" : ":"), "JULIA_LOAD_PATH" => nothing) do

0 commit comments

Comments
 (0)