Skip to content

Commit

Permalink
Merge pull request #23 from JuliaPluto/uncurly
Browse files Browse the repository at this point in the history
unescape name in uncurly!
  • Loading branch information
Pangoraw committed Sep 9, 2024
2 parents 8a83345 + 9f8a562 commit 78cea1c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "ExpressionExplorer"
uuid = "21656369-7473-754a-2065-74616d696c43"
license = "MIT"
authors = ["Paul Berg <paul@plutojl.org>", "Fons van der Plas <fons@plutojl.org>"]
version = "1.0.3"
version = "1.0.4"

[compat]
julia = "1.6"
Expand Down
5 changes: 4 additions & 1 deletion src/explore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,9 @@ function to_kw(ex::Expr)
end
to_kw(x) = x

unescape(x::Expr) = Meta.isexpr(x, :escape) ? x.args[1] : x
unescape(x) = x

"""
Return the function name and the SymbolsState from argument defaults. Add arguments as hidden globals to the `scopestate`.
Expand Down Expand Up @@ -975,7 +978,7 @@ function explore_funcdef!(ex::Expr, scopestate::ScopeState)::Tuple{FunctionName,

elseif ex.head === :(<:)
# for use in `struct`, `abstract` and `primitive`
name, symstate = uncurly!(ex.args[1], scopestate)
name, symstate = uncurly!(unescape(ex.args[1]), scopestate)
if length(ex.args) != 1
union!(symstate, explore!(ex.args[2], scopestate))
end
Expand Down
8 changes: 7 additions & 1 deletion test/ExpressionExplorer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ end
@test_nowarn testee(:(function f(function g() end) end), [], [], [:+], [], verbose=false)
@test_nowarn testee(:(function f() Base.sqrt(x::String) = 2; end), [], [], [:+], [], verbose=false)
@test_nowarn testee(:(function f() global g(x) = x; end), [], [], [], [], verbose=false)

@test_nowarn testee(:(primitive type $(esc(:Fruit)) <: T 32 end), [], [:Fruit], [], [
:Fruit => ([:T], [], [], [])
])
end
@testset "Lists and structs" begin
@test testee(:(1:3), [], [], [:(:)], [])
Expand Down Expand Up @@ -99,7 +103,9 @@ end
@test testee(:(primitive type Int24 <: Integer size end), [:size], [:Int24], [], [
:Int24 => ([:Integer], [], [], [])
])

@test_nowarn testee(:(primitive type $(esc(:Fruit)) <: T 32 end), [], [:Fruit], [], [
:Fruit => ([:T], [], [], [])
])
@test testee(:(module a; f(x) = x; z = r end), [], [:a], [], [])
end
@testset "Types" begin
Expand Down

2 comments on commit 78cea1c

@Pangoraw
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/114860

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.4 -m "<description of version>" 78cea1cd1c4a7751ba84b55e56b6b0b2bbfa6f63
git push origin v1.0.4

Please sign in to comment.