Skip to content

Commit

Permalink
Workaround lowering error in docstring method signatures
Browse files Browse the repository at this point in the history
This patch adds a (minimal?) targeted hack to workaround an issue where
a method signature for documentation fails lowering (#735).

Specifically, when revising the following code:

```julia
struct Foo{T} end

"docs"
Foo{T}(::Int) where T
```

lowering errors for the expression `:(Foo{T}(::Int) where T)` with
`"invalid :: syntax"`. This patch simply ignores the expression when
this situation is detected. Note that, just after, the full expression
(docstring + signature) is lowered together succesfully. In particular
this means that the docstring will still be updated correctly.
  • Loading branch information
fredrikekre committed Nov 9, 2023
1 parent 6f71e52 commit 8773bd4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lowered.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ function methods_by_execution!(@nospecialize(recurse), methodinfo, docexprs, mod
mode (:sigs, :eval, :evalmeth, :evalassign) || error("unsupported mode ", mode)
lwr = Meta.lower(mod, ex)
isa(lwr, Expr) || return nothing, nothing
# Targeted hack around https://github.com/timholy/Revise.jl/issues/735
if Meta.isexpr(lwr, :error, 1) && lwr.args[1] == "invalid \"::\" syntax" &&
mode === :sigs
@debug "methods_by_execution!: skipping expression where lowering failed " *
"(see https://github.com/timholy/Revise.jl/issues/735)" expr=ex lowered=lwr
return nothing, nothing
end
if lwr.head === :error || lwr.head === :incomplete
error("lowering returned an error, ", lwr)
end
Expand Down

0 comments on commit 8773bd4

Please sign in to comment.