enso-org / enso

Enso Analytics is a self-service data prep and analysis platform designed for data teams.
https://ensoanalytics.com
Apache License 2.0
7.36k stars 322 forks source link

Lines numbers are off in stack traces #3728

Open diab0l opened 2 years ago

diab0l commented 2 years ago

General Summary

Developing code in the cli, I noticed that line numbers are often off for code which produces errors in another module. It does not appear to make a difference whether one catches the error or lets it bubble up.

In the reproduction below, the line numbers are reported as 1, but I have seen cases where line numbers where off by 1-3 lines (and the columns way off as in Wrong column numbers for Enso stacktraces when accessed from Java).

Steps to Reproduce

  1. Create a new project
  2. Create Main.enso as below
  3. Create Module.enso as below
  4. enso run the project

Main.enso:

from Standard.Base import all
from project.Module import f

main =
    Panic.catch Any handler=(p-> p.stack_trace.each IO.println) <| 
        f [ "" ]

Module.enso:

from Standard.Base import all

f : Any -> Any
f xs =
    extract_cs x = case x of 
        Nothing -> [ 1 ]
        _ -> [ 2 ]
    foo = extract_cs xs
    Panic.throw "err"

Expected Result

Something like

(Stack_Trace_Element_Data 'Panic.throw' Nothing)
(Stack_Trace_Element_Data 'Module.f' (Source_Location src/Module.enso:9:1-22))
(Stack_Trace_Element_Data 'argument<1>' (Source_Location src/Main.enso:6:9-17))
(Stack_Trace_Element_Data 'Panic.primitive_get_attached_stack_trace' Nothing)
(Stack_Trace_Element_Data 'Panic.get_attached_stack_trace' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:323:22-71))
(Stack_Trace_Element_Data 'Caught_Panic.stack_trace' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:250:9-43))
(Stack_Trace_Element_Data 'argument<0>' (Source_Location src/Main.enso:5:34-46))
(Stack_Trace_Element_Data '<anonymous>' (Source_Location src/Main.enso:5:34-62))
(Stack_Trace_Element_Data 'case_branch' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:385:29-48))
(Stack_Trace_Element_Data 'case_branch' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:384-386))
(Stack_Trace_Element_Data '<anonymous>' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:383-392))
(Stack_Trace_Element_Data 'Panic.catch_primitive' Nothing)
(Stack_Trace_Element_Data 'Panic.catch' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:382-392))
(Stack_Trace_Element_Data 'Function.<|' Nothing)
(Stack_Trace_Element_Data 'Main.main' (Source_Location src/Main.enso:5-6))
(Stack_Trace_Element_Data 'org.graalvm.polyglot.Value<Function>.execute' Nothing)

Line numbers relating to Main.main and Module.f should correspond to their definitions and the invocations.

Actual Result

(Stack_Trace_Element_Data 'Panic.throw' Nothing)
(Stack_Trace_Element_Data 'Module.f' (Source_Location src/Module.enso:1:1-1))
(Stack_Trace_Element_Data 'argument<1>' (Source_Location src/Main.enso:1:1-1))
(Stack_Trace_Element_Data 'Panic.primitive_get_attached_stack_trace' Nothing)
(Stack_Trace_Element_Data 'Panic.get_attached_stack_trace' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:323:22-71))
(Stack_Trace_Element_Data 'Caught_Panic.stack_trace' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:250:9-43))
(Stack_Trace_Element_Data 'argument<0>' (Source_Location src/Main.enso:5:34-46))
(Stack_Trace_Element_Data '<anonymous>' (Source_Location src/Main.enso:5:34-62))
(Stack_Trace_Element_Data 'case_branch' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:385:29-48))
(Stack_Trace_Element_Data 'case_branch' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:384-386))
(Stack_Trace_Element_Data '<anonymous>' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:383-392))
(Stack_Trace_Element_Data 'Panic.catch_primitive' Nothing)
(Stack_Trace_Element_Data 'Panic.catch' (Source_Location /home/wsl/.local/enso/dist/2022.1.1-nightly.2022-09-15/lib/Standard/Base/2022.1.1-nightly.2022-09-15/src/Error/Common.enso:382-392))
(Stack_Trace_Element_Data 'Function.<|' Nothing)
(Stack_Trace_Element_Data 'Main.main' (Source_Location src/Main.enso:1:1-1))
(Stack_Trace_Element_Data 'org.graalvm.polyglot.Value<Function>.execute' Nothing)

Line numbers are 1.

Enso Version

Enso Launcher
Version:    2022.1.1-nightly.2022-09-15
Built with: scala-2.13.8 for GraalVM 21.3.0
Built from: develop @ 605bd08e8dd4a8b7242c5b51bf19d5213fa127c2
Built on:   Linux (amd64)
Enso engine from project Line_number_repro:
Enso Compiler and Runtime
Version:    2022.1.1-nightly.2022-09-15
Built with: scala-2.13.8 for GraalVM 21.3.0
Built from: develop @ 605bd08e8dd4a8b7242c5b51bf19d5213fa127c2
Running on: OpenJDK 64-Bit Server VM, GraalVM Community, JDK 11.0.13+7-jvmci-21.3-b05
            Linux 4.19.104-microsoft-standard (amd64)
radeusgd commented 1 year ago

Hello @diab0l, I've checked the provided steps on one of the latest builds and I could not reproduce the issue - the line numbers were displayed correctly for me.

Could you please check if you can still reproduce the issue or if we can mark it as resolved?