tremor-rs / tremor-runtime

Main Tremor Project Rust Codebase
https://www.tremor.rs
Apache License 2.0
851 stars 126 forks source link

Tremor Script error messages point to wrong expression #162

Closed m0n0chr0m3 closed 4 months ago

m0n0chr0m3 commented 4 years ago

Problem In Tremor Script, indexing into something which is not an array results in an error message. Consider e.g. the one in tests/script_runtime_errors/non_arr_access2/error.txt, which reads as follows:

Error: 
    1 | event.snot[42]
      |            ^^ Conflicting types, got integer but expected array

The error message points to the index 42, but the type error is due to the type of event.snot. A more correct error message could be:

Error: 
    1 | event.snot[42]
      |       ^^^^ Conflicting types, got integer but expected array

Steps To reproduce, index into something that's not an array, e.g. as done in tests/script_runtime_errors/non_arr_access/, tests/script_runtime_errors/non_arr_access2/, tests/script_runtime_errors/subslice_no_arr/, and perhaps others.

Possible Solution(s) A solution may involve modifying the inner expression passed to error_need_arr in tremor-script::interpreter::resolve.

darach commented 4 months ago

Closing. This was fixed via #1672