Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type error within struct reported without actual error line #38531

Open
paulmelis opened this issue Nov 22, 2020 · 1 comment
Open

Type error within struct reported without actual error line #38531

paulmelis opened this issue Nov 22, 2020 · 1 comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) error messages Better, more actionable error messages

Comments

@paulmelis
Copy link
Contributor

Reduction from a larger struct in which I was specifying the type of the nb field incorrectly:

melis@juggle 23:28:~$ cat t.jl
struct S
    field1::Bool
    field2::String
    # Error is here
    nb::Matrix{UInt8, UInt8}
end
melis@juggle 23:28:~$ julia t.jl
ERROR: LoadError: too many parameters for type
Stacktrace:
 [1] top-level scope at /home/melis/t.jl:1
in expression starting at /home/melis/t.jl:1

The error line reported is the start of the struct definition, which is only of limited value. As I'm a julia beginner I don't immediately spot these errors within the struct and need to check for the offending line by commenting several fields and rerunning. Would it be possible to report the actual line involved? This is especially useful when structs start to contain many fields.

julia> versioninfo()
Julia Version 1.5.2
Commit 539f3ce943* (2020-09-23 23:17 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-10.0.1 (ORCJIT, haswell)
@brenhinkeller brenhinkeller added the error handling Handling of exceptions by Julia or the user label Nov 20, 2022
@nsajko nsajko added the error messages Better, more actionable error messages label Jan 28, 2024
@vtjnash
Copy link
Member

vtjnash commented Feb 1, 2024

The error message is improved now, but lowering still fails to report the correct line number, even though that information was present in the parsed file and so it should be capable of preserving it.

julia> struct S
           field1::Bool
           field2::String
           # Error is here
           nb::Matrix{UInt8, UInt8}
       end
ERROR: too many parameters for type Array
Stacktrace:
 [1] top-level scope
   @ REPL[1]:1

@vtjnash vtjnash added compiler:lowering Syntax lowering (compiler front end, 2nd stage) and removed error handling Handling of exceptions by Julia or the user labels Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) error messages Better, more actionable error messages
Projects
None yet
Development

No branches or pull requests

4 participants