Skip to content

Commit

Permalink
Fix variable scope (#21)
Browse files Browse the repository at this point in the history
It seems in julia 1.10, the variable needs to be declared outside of the
`try`/`if` block, otherwise it complains

```julia
ERROR: LoadError: UndefVarError: `format` not defined
```
  • Loading branch information
qiaojunfeng authored Jan 15, 2024
1 parent e80f6f1 commit d84a223
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 2 additions & 5 deletions src/w90/nnkp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,11 @@ function read_nnkp(filename::AbstractString, ::Wannier90Toml)
end

function read_nnkp(filename::AbstractString)
format = Wannier90Text()
try
TOML.parsefile(filename)
catch err
if err isa TOML.ParserError
format = Wannier90Text()
else
rethrow()
end
err isa TOML.ParserError || rethrow()
else
format = Wannier90Toml()
end
Expand Down
7 changes: 2 additions & 5 deletions src/w90/win.jl
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,11 @@ function read_win(filename::AbstractString, ::Wannier90Toml; fix_inputs::Bool=tr
end

function read_win(filename::AbstractString; fix_inputs=true)
format = Wannier90Text()
try
TOML.parsefile(filename)
catch err
if err isa TOML.ParserError
format = Wannier90Text()
else
rethrow()
end
err isa TOML.ParserError || rethrow()
else
format = Wannier90Toml()
end
Expand Down

0 comments on commit d84a223

Please sign in to comment.