COMCIFS / cif_core

The IUCr CIF core dictionary
15 stars 9 forks source link

Unicode bug in layout checker? #414

Closed rowlesmr closed 1 year ago

rowlesmr commented 1 year ago

Commit 0ebe2f8 fails in #413 .

The complete error message is:

Run julia -e 'using Pkg; Pkg.status()'
      Status `~/.julia/environments/v1.6/Project.toml`
  [c7e460c6] ArgParse v1.1.4
  [6007d9b0] CrystalInfoFramework v0.5.2
  [8fc22ac5] FilePaths v0.8.3
  [d42ef402] Lerche v0.5.4
Checking main/cif_core.dic

Lint report for main/cif_core.dic
=================================

Imports relative to /home/runner/work/cif_core/cif_core/cif_core

Layout:

ERROR: LoadError: StringIndexError: invalid index [21], valid nearby indices [20]=>'°', [22]=>'''
Stacktrace:
  [1] string_index_err(s::Token, i::Int64)
    @ Base ./strings/string.jl:12
  [2] SubString{Token}(s::Token, i::Int64, j::Int64)
    @ Base ./strings/substring.jl:32
  [3] SubString
    @ ./strings/substring.jl:38 [inlined]
  [4] SubString
    @ ./strings/substring.jl:40 [inlined]
  [5] getindex
    @ ./strings/substring.jl:255 [inlined]
  [6] check_delimiter(value::Tree)
    @ Main ~/work/cif_core/cif_core/julia_cif_tools/layout.jl:5[14](https://github.com/COMCIFS/cif_core/actions/runs/5166639799/jobs/9306964395?pr=413#step:9:15)
  [7] transformer_func(l::Linter, #unused#::Val{:scalar_item}, meta::Lerche.Meta, tree::Tree)
    @ Main ~/work/cif_core/cif_core/julia_cif_tools/layout.jl:491
  [8] _call_userfunc(v::Linter, tree::Tree)
    @ Lerche ~/.julia/packages/Lerche/QxD5R/src/visitors.jl:[26](https://github.com/COMCIFS/cif_core/actions/runs/5166639799/jobs/9306964395?pr=413#step:9:27)9
  [9] visit(v::Linter, tree::Tree)
    @ Lerche ~/.julia/packages/Lerche/QxD5R/src/visitors.jl:[29](https://github.com/COMCIFS/cif_core/actions/runs/5166639799/jobs/9306964395?pr=413#step:9:30)9
 [10] visit(v::Linter, tree::Tree) (repeats 5 times)
    @ Lerche ~/.julia/packages/Lerche/QxD5R/src/visitors.jl:296
 [11] lint_report(filename::String; ref_dic::String, import_dir::String, warn::Bool, no_text::Bool)
    @ Main ~/work/cif_core/cif_core/julia_cif_tools/linter.jl:[50](https://github.com/COMCIFS/cif_core/actions/runs/5166639799/jobs/9306964395?pr=413#step:9:51)
 [12] top-level scope
    @ ~/work/cif_core/cif_core/julia_cif_tools/linter.jl:107
in expression starting at /home/runner/work/cif_core/cif_core/julia_cif_tools/linter.jl:104
Error: Process completed with exit code 1.

I don't think it can cope with the unicode next to the ' character. If I add a space inbetween, then the failure moves down to

ERROR: LoadError: StringIndexError: invalid index [3], valid nearby indices [2]=>'κ', [4]=>'-'
Stacktrace:
  [1] string_index_err(s::Token, i::Int64)
    @ Base ./strings/string.jl:12
  [2] SubString{Token}(s::Token, i::Int64, j::Int64)
    @ Base ./strings/substring.jl:[32](https://github.com/COMCIFS/cif_core/actions/runs/5166691101/jobs/9307058118?pr=413#step:9:33)
  [3] SubString
    @ ./strings/substring.jl:[38](https://github.com/COMCIFS/cif_core/actions/runs/5166691101/jobs/9307058118?pr=413#step:9:39) [inlined]
  [4] SubString
    @ ./strings/substring.jl:[40](https://github.com/COMCIFS/cif_core/actions/runs/5166691101/jobs/9307058118?pr=413#step:9:41) [inlined]
  [5] getindex
    @ ./strings/substring.jl:255 [inlined]
  [6] get_delimiter(value::Token)
    @ Main ~/work/cif_core/cif_core/julia_cif_tools/layout.jl:84
  [7] get_delimiter(value::Tree)
    @ Main ~/work/cif_core/cif_core/julia_cif_tools/layout.jl:79
  [8] get_delimiter(value::Tree)
    @ Main ~/work/cif_core/cif_core/julia_cif_tools/layout.jl:75
  [9] get_delimiter_with_val(v::Tree)
    @ Main ~/work/cif_core/cif_core/julia_cif_tools/layout.jl:94
 [10] check_loop_delimiters(name_list::Vector{Union{Token, Tree}}, value_list::Vector{Union{Token, Tree}})
    @ Main ~/work/cif_core/cif_core/julia_cif_tools/layout.jl:255
 [11] transformer_func(l::Linter, #unused#::Val{:loop}, meta::Lerche.Meta, tree::Tree)
    @ Main ~/work/cif_core/cif_core/julia_cif_tools/layout.jl:224
 [12] _call_userfunc(v::Linter, tree::Tree)
    @ Lerche ~/.julia/packages/Lerche/QxD5R/src/visitors.jl:269
 [13] visit(v::Linter, tree::Tree)
    @ Lerche ~/.julia/packages/Lerche/QxD5R/src/visitors.jl:299
 [14] visit(v::Linter, tree::Tree) (repeats 5 times)
    @ Lerche ~/.julia/packages/Lerche/QxD5R/src/visitors.jl:296
 [15] lint_report(filename::String; ref_dic::String, import_dir::String, warn::Bool, no_text::Bool)
    @ Main ~/work/cif_core/cif_core/julia_cif_tools/linter.jl:[50](https://github.com/COMCIFS/cif_core/actions/runs/5166691101/jobs/9307058118?pr=413#step:9:51)
 [16] top-level scope
    @ ~/work/cif_core/cif_core/julia_cif_tools/linter.jl:107
in expression starting at /home/runner/work/cif_core/cif_core/julia_cif_tools/linter.jl:104
Error: Process completed with exit code 1.
vaitkus commented 1 year ago

Issue is probably more suited for the https://github.com/jamesrhester/julia_cif_tools repository.

jamesrhester commented 1 year ago

Thanks, it is due to unicode and I will fix it.