Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TypedSyntax/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TypedSyntax"
uuid = "d265eb64-f81a-44ad-a842-4247ee1503de"
authors = ["Tim Holy <[email protected]> and contributors"]
version = "1.5.1"
version = "1.5.2"

[deps]
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
Expand Down
14 changes: 8 additions & 6 deletions TypedSyntax/src/node.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,25 @@ end
# Recursive construction of the TypedSyntaxNode tree from the SyntaxNodeTree
function addchildren!(tparent, parent, src::CodeInfo, node2ssa, symtyps, mappings)
if !is_leaf(parent)
if tparent.children === nothing
tparent.children = TypedSyntaxNode[]
end
for child in children(parent)
typ = gettyp(node2ssa, child, src)
tnode = TypedSyntaxNode(tparent, nothing, TypedSyntaxData(child.data::SyntaxData, src, typ))
if tnode.typ === nothing && (#=is_literal(child) ||=# kind(child) == K"Identifier")
tnode.typ = get(symtyps, child, nothing)
end
is_leaf(tparent) && (tparent.children = TypedSyntaxNode[])
push!(tparent, tnode)
addchildren!(tnode, child, src, node2ssa, symtyps, mappings)
end
end
# In `return f(args..)`, copy any types assigned to `f(args...)` up to the `[return]` node
if kind(tparent) == K"return" && !is_leaf(tparent)
childs = children(tparent)
tparent.typ = isempty(childs) ? Nothing : only(childs).typ
if kind(tparent) == K"return"
if !is_leaf(tparent)
value = only(children(tparent))
tparent.typ = value.typ
else
tparent.typ = Nothing
end
end
# Replace the entry in `mappings` to be the typed node
i = get(node2ssa, parent, nothing)
Expand Down
6 changes: 6 additions & 0 deletions test/test_codeview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,10 @@ end
end
end

@testset "Regressions" begin
# Issue #675
(; src, infos, codeinst, rt, exct, effects, slottypes) = cthulhu_info(NamedTuple; optimize=false)
Cthulhu.cthulhu_typed(IOBuffer(), :none, src, rt, exct, effects, codeinst; annotate_source=true)
end

end # module test_codeview
Loading