Skip to content

Commit

Permalink
Merge pull request #120 from SymbolicML/fix-error
Browse files Browse the repository at this point in the history
Fix error message for `us"Constants.*"`
  • Loading branch information
MilesCranmer committed Mar 5, 2024
2 parents 5363018 + 3087099 commit 73df126
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/symbolic_dimensions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ module SymbolicUnits
if sym in UNIT_SYMBOLS
return lookup_unit(sym)
elseif sym in CONSTANT_SYMBOLS
throw(ArgumentError("Symbol $sym found in `SymbolicConstants` but not `SymbolicUnits`. Please access the `SymbolicConstants` module. For example, `u\"SymbolicConstants.$sym\"`."))
throw(ArgumentError("Symbol $sym found in `Constants` but not `Units`. Please use `us\"Constants.$sym\"` instead."))
else
throw(ArgumentError("Symbol $sym not found in `SymbolicUnits` or `SymbolicConstants`."))
throw(ArgumentError("Symbol $sym not found in `Units` or `Constants`."))
end
end
function map_to_scope(ex)
Expand Down
2 changes: 1 addition & 1 deletion src/uparse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function map_to_scope(sym::Symbol)
if sym in UNIT_SYMBOLS
return lookup_unit(sym)
elseif sym in CONSTANT_SYMBOLS
throw(ArgumentError("Symbol $sym found in `Constants` but not `Units`. Please access the `Constants` module. For example, `u\"Constants.$sym\"`."))
throw(ArgumentError("Symbol $sym found in `Constants` but not `Units`. Please use `u\"Constants.$sym\"` instead."))
else
throw(ArgumentError("Symbol $sym not found in `Units` or `Constants`."))
end
Expand Down
2 changes: 1 addition & 1 deletion test/unittests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ end
VERSION >= v"1.9" && @test_throws "Unexpected expression" uparse("(m, m)")
@test_throws LoadError eval(:(us"x"))
VERSION >= v"1.9" && @test_throws "Symbol x not found" sym_uparse("x")
VERSION >= v"1.9" && @test_throws "Symbol c found in `SymbolicConstants` but not `SymbolicUnits`" sym_uparse("c")
VERSION >= v"1.9" && @test_throws "Symbol c found in `Constants` but not `Units`" sym_uparse("c")
VERSION >= v"1.9" && @test_throws "Unexpected expression" sym_uparse("import ..Units")
VERSION >= v"1.9" && @test_throws "Unexpected expression" sym_uparse("(m, m)")
end
Expand Down

0 comments on commit 73df126

Please sign in to comment.