Skip to content

Commit b70e7f7

Browse files
committed
fix: issues spotted by JET
1 parent 25b937f commit b70e7f7

File tree

7 files changed

+32
-13
lines changed

7 files changed

+32
-13
lines changed

src/DynamicExpressions.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,17 @@ include("deprecated.jl")
7373

7474
import TOML: parsefile
7575

76-
const PACKAGE_VERSION = let
77-
project = parsefile(joinpath(pkgdir(@__MODULE__), "Project.toml"))
78-
VersionNumber(project["version"])
76+
const PACKAGE_VERSION = let d = pkgdir(@__MODULE__)
77+
try
78+
if d isa String
79+
project = parsefile(joinpath(d, "Project.toml"))
80+
VersionNumber(project["version"])
81+
else
82+
v"0.0.0"
83+
end
84+
catch
85+
v"0.0.0"
86+
end
7987
end
8088

8189
macro ignore(args...) end

src/EvaluateDerivative.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ end
8080
end
8181
end
8282
deg2_branch = if nbin > OPERATOR_LIMIT_BEFORE_SLOWDOWN
83-
diff_deg2_eval(tree, cX, operators.binops[op_idx], operators, direction)
83+
quote
84+
diff_deg2_eval(tree, cX, operators.binops[op_idx], operators, direction)
85+
end
8486
else
8587
quote
8688
Base.Cartesian.@nif(

src/Expression.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ import ..NodeUtilsModule:
213213
set_constants!
214214

215215
#! format: off
216-
count_constants(ex::AbstractExpression; kws...) = count_constants(get_tree(ex); kws...)
217-
count_depth(ex::AbstractExpression; kws...) = count_depth(get_tree(ex); kws...)
216+
count_constants(ex::AbstractExpression) = count_constants(get_tree(ex))
217+
count_depth(ex::AbstractExpression) = count_depth(get_tree(ex))
218218
index_constants(ex::AbstractExpression, ::Type{T}=UInt16) where {T} = index_constants(get_tree(ex), T)
219219
has_operators(ex::AbstractExpression) = has_operators(get_tree(ex))
220220
has_constants(ex::AbstractExpression) = has_constants(get_tree(ex))
@@ -310,14 +310,14 @@ end
310310
import ..SimplifyModule: combine_operators, simplify_tree!
311311

312312
# Avoid implementing a generic version for these, as it is less likely to generalize
313-
function combine_operators(ex::Expression, operators=nothing; kws...)
313+
function combine_operators(ex::Expression, operators=nothing)
314314
return Expression(
315-
combine_operators(get_tree(ex), get_operators(ex, operators); kws...), ex.metadata
315+
combine_operators(get_tree(ex), get_operators(ex, operators)), ex.metadata
316316
)
317317
end
318-
function simplify_tree!(ex::Expression, operators=nothing; kws...)
318+
function simplify_tree!(ex::Expression, operators=nothing)
319319
return Expression(
320-
simplify_tree!(get_tree(ex), get_operators(ex, operators); kws...), ex.metadata
320+
simplify_tree!(get_tree(ex), get_operators(ex, operators)), ex.metadata
321321
)
322322
end
323323

src/OperatorEnumConstruction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function set_default_variable_names!(variable_names::Vector{String})
8282
return LATEST_VARIABLE_NAMES.x = copy(variable_names)
8383
end
8484

85-
Base.@deprecate create_evaluation_helpers! set_default_operators!
85+
Base.@deprecate create_evaluation_helpers!(operators) set_default_operators!(operators)
8686

8787
function set_default_operators!(operators::OperatorEnum)
8888
LATEST_OPERATORS.x = operators

src/deprecated.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Base: @deprecate
22
import .NodeModule: Node, GraphNode
33

4-
@deprecate set_constants set_constants!
5-
@deprecate simplify_tree simplify_tree!
4+
@deprecate set_constants(tree, constants) set_constants!(tree, constants)
5+
@deprecate simplify_tree(tree, operators) simplify_tree!(tree, operators)
66

77
for N in (:Node, :GraphNode)
88
@eval begin

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
55
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
66
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
77
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
8+
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
89
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
910
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
1011
Optim = "429524aa-4258-5aef-a3af-852621145aeb"

test/unittest.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,11 @@ end
135135
@testitem "Test parametric expression" begin
136136
include("test_parametric_expression.jl")
137137
end
138+
139+
@testitem "JET" begin
140+
using DynamicExpressions
141+
using JET
142+
if VERSION >= v"1.10"
143+
JET.test_package(DynamicExpressions; target_defined_modules=true)
144+
end
145+
end

0 commit comments

Comments
 (0)