Skip to content

Commit

Permalink
Minor tweaks to remove method ambiguities and argument ambiguities
Browse files Browse the repository at this point in the history
These were harmless enough, but should satisfy the tests in Base.

Also remove a display_error() overload because (a) it's not designed to
be overridden, and (b) this override doesn't really have the intended
effect anyway in the latest version where the REPL uses exception stacks
more extensively.
  • Loading branch information
c42f committed May 25, 2023
1 parent 671841b commit 3598a2b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 0 additions & 3 deletions src/parser_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ function Base.showerror(io::IO, err::ParseError)
show_diagnostics(io, err.diagnostics, err.source)
end

Base.display_error(io::IO, err::ParseError, bt) = Base.showerror(io, err, bt)


"""
parse!(stream::ParseStream; rule=:all)

Expand Down
8 changes: 8 additions & 0 deletions src/syntax_tree.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ mutable struct TreeNode{NodeData} # ? prevent others from using this with Node
parent::Union{Nothing,TreeNode{NodeData}}
children::Union{Nothing,Vector{TreeNode{NodeData}}}
data::Union{Nothing,NodeData}

# Use this constructor rather than the automatically generated one to pass
# Test.detect_unbound_args() test in Base.
function TreeNode{NodeData}(parent::Union{Nothing,TreeNode{NodeData}},
children::Union{Nothing,Vector{TreeNode{NodeData}}},
data::Union{Nothing,NodeData}) where {NodeData}
new{NodeData}(parent, children, data)
end
end

# Implement "pass-through" semantics for field access: access fields of `data`
Expand Down
2 changes: 1 addition & 1 deletion src/tokenize.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Tokenize

export tokenize, untokenize, Tokens
export tokenize, untokenize

using ..JuliaSyntax: JuliaSyntax, Kind, @K_str, @KSet_str

Expand Down
7 changes: 7 additions & 0 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@
@test ps("XX", fgcolor=:red, bgcolor=:green, href="https://www.example.com") ==
"\e]8;;https://www.example.com\e\\\e[31m\e[42mXX\e[0;0m\e]8;;\e\\"
end

@testset "ambiguities" begin
if VERSION >= v"1.8"
@test detect_ambiguities(JuliaSyntax) == []
@test detect_unbound_args(JuliaSyntax) == []
end
end

0 comments on commit 3598a2b

Please sign in to comment.