Skip to content

Commit

Permalink
Add some typeasserts to reduce invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed May 18, 2020
1 parent 11c104e commit fbe8af8
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions base/Enums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ macro enum(T, syms...)
else
throw(ArgumentError(string("invalid argument for Enum ", typename, ": ", s)))
end
s = s::Symbol
if !Base.isidentifier(s)
throw(ArgumentError("invalid name for Enum $typename; \"$s\" is not a valid identifier"))
end
Expand Down
2 changes: 1 addition & 1 deletion base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ function show_import_path(io::IO, ex, quote_level)
if i > 1 && ex.args[i-1] !== :(.)
print(io, '.')
end
show_sym(io, ex.args[i], allow_macroname=(i==length(ex.args)))
show_sym(io, ex.args[i]::Symbol, allow_macroname=(i==length(ex.args)))
end
else
show_unquoted(io, ex, 0, 0, quote_level)
Expand Down
2 changes: 1 addition & 1 deletion base/strings/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ julia> cmp("b", "β")
function cmp(a::AbstractString, b::AbstractString)
a === b && return 0
a, b = Iterators.Stateful(a), Iterators.Stateful(b)
for (c, d) in zip(a, b)
for (c::AbstractChar, d::AbstractChar) in zip(a, b)
c d && return ifelse(c < d, -1, 1)
end
isempty(a) && return ifelse(isempty(b), 0, -1)
Expand Down
6 changes: 3 additions & 3 deletions stdlib/LibGit2/src/gitcredential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ end

function Base.read!(io::IO, cred::GitCredential)
# https://git-scm.com/docs/git-credential#IOFMT
while !eof(io)
key = readuntil(io, '=')
while !(eof(io)::Bool)
key::AbstractString = readuntil(io, '=')
if key == "password"
value = Base.SecretBuffer()
while !eof(io) && (c = read(io, UInt8)) != UInt8('\n')
while !(eof(io)::Bool) && (c = read(io, UInt8)) != UInt8('\n')
write(value, c)
end
seekstart(value)
Expand Down
6 changes: 3 additions & 3 deletions stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,9 @@ moduleusings(mod) = ccall(:jl_module_usings, Any, (Any,), mod)
filtervalid(names) = filter(x->!occursin(r"#", x), map(string, names))

accessible(mod::Module) =
[filter!(s -> !Base.isdeprecated(mod, s), names(mod, all = true, imported = true));
map(names, moduleusings(mod))...;
collect(keys(Base.Docs.keywords))] |> unique |> filtervalid
Symbol[filter!(s -> !Base.isdeprecated(mod, s), names(mod, all=true, imported=true));
map(names, moduleusings(mod))...;
collect(keys(Base.Docs.keywords))] |> unique |> filtervalid

doc_completions(name) = fuzzysort(name, accessible(Main))
doc_completions(name::Symbol) = doc_completions(string(name))
Expand Down

0 comments on commit fbe8af8

Please sign in to comment.