From 71d2ad396463522e11e568aeeed0382a1070e8ce Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:22:24 +0200 Subject: [PATCH 1/4] Fix passing symbols to `trixi_include` --- src/trixi_include.jl | 7 +++++-- test/trixi_include.jl | 9 +++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/trixi_include.jl b/src/trixi_include.jl index 00a7131..37f6f13 100644 --- a/src/trixi_include.jl +++ b/src/trixi_include.jl @@ -200,7 +200,9 @@ function replace_assignments(expr, recursive = false; kwargs...) for (key, val) in kwargs if (x.head === Symbol("=") || x.head === :kw) && x.args[1] === Symbol(key) - x.args[2] = :($val) + # Symbols need to be quoted so that they are evaluated as values instead + # of variable names in the included file. + x.args[2] = val isa Symbol ? QuoteNode(val) : val # dump(x) end end @@ -242,7 +244,8 @@ function replace_assignments(expr, recursive = false; kwargs...) # `x = ...` in the file, which will also be replaced in the loop above. for (key, val) in kwargs if !(Symbol(key) in existing_kwargs) - push!(x.args, Expr(:kw, Symbol(key), val)) + value = val isa Symbol ? QuoteNode(val) : val + push!(x.args, Expr(:kw, Symbol(key), value)) end end end diff --git a/test/trixi_include.jl b/test/trixi_include.jl index b41f389..150ae10 100644 --- a/test/trixi_include.jl +++ b/test/trixi_include.jl @@ -29,6 +29,15 @@ @test x == 7 end + @trixi_test_nowarn trixi_include(@__MODULE__, path, x = :symbol) + + if VERSION >= v"1.12" + mod = @__MODULE__ + @test (@invokelatest mod.x) === :symbol + else + @test x === :symbol + end + # Verify default version (that includes in `Main`) @trixi_test_nowarn trixi_include(path, x = 11) if VERSION >= v"1.12" From 86ec9ef31e92dde6ee329631383a5c234fd785b2 Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:24:00 +0200 Subject: [PATCH 2/4] Update version number --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 58ac5c7..7f5de25 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "TrixiBase" uuid = "9a0f1c46-06d5-4909-a5a3-ce25d3fa3284" authors = ["Michael Schlottke-Lakemper "] -version = "0.1.11-DEV" +version = "0.1.11" [deps] ChangePrecision = "3cb15238-376d-56a3-8042-d33272777c9a" From ab9ada1c9be4c60a799ff14a2aeb4abe05ead0f7 Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:30:17 +0200 Subject: [PATCH 3/4] Add additional test --- test/trixi_include.jl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/trixi_include.jl b/test/trixi_include.jl index 150ae10..9dc5c7a 100644 --- a/test/trixi_include.jl +++ b/test/trixi_include.jl @@ -205,6 +205,20 @@ @test y == 20 # Overridden from nested file @test z == 30 # Overridden from top file end + + # Test a Symbol override that is only assigned in the nested file. + # This covers the branch where missing kwargs are injected + # into the nested `trixi_include` call. + @test_warn "assignments" trixi_include(@__MODULE__, path2; + x = :symbol, + replace_assignments_recursive = true) + if VERSION >= v"1.12" + mod = @__MODULE__ + @test (@invokelatest mod.x) === :symbol + else + @test x === :symbol + end + # Test that kwargs are NOT passed recursively @trixi_test_nowarn trixi_include(@__MODULE__, path2; x = 10, y = 20, z = 30, From 08c144aa1e842b9909bb0de992adac0cb7ccb558 Mon Sep 17 00:00:00 2001 From: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com> Date: Tue, 25 Aug 2026 10:12:06 +0200 Subject: [PATCH 4/4] Test overwriting kwarg with symbol --- test/trixi_include.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/trixi_include.jl b/test/trixi_include.jl index 9dc5c7a..67bc969 100644 --- a/test/trixi_include.jl +++ b/test/trixi_include.jl @@ -278,6 +278,16 @@ @test a == 500 # Top-level override wins over nested explicit kwarg @test b == 600 # Passed through to nested file end + + # Test overwriting an existing nested kwarg with a Symbol. + @trixi_test_nowarn trixi_include(@__MODULE__, path4; a = :symbol, + replace_assignments_recursive = true) + if VERSION >= v"1.12" + mod = @__MODULE__ + @test (@invokelatest mod.a) === :symbol + else + @test a === :symbol + end end end