~jonsterling/forester-devel

3 2

Regression: import hides diagnostic errors

Details
Message ID
<D5RUW5E8OO4T.1C2E4PPPN8D02@cs.ox.ac.uk>
DKIM signature
missing
Download raw message
Patch: +1 -0
(Apologies if you get multiple copies of this bug report, I tried
sending it directly to ~jonsterling/forester@todo.sr.ht but for whatever
reason that didn't work.)

In forester 5.0 dev, if you start a new forest with two files as such:

index.tree: <empty file>

new.tree:
  ```forester
  \import{index}
  \p{
    \foo#notexists
  }
  ```

and run `forester build`, you get the following error:

```
  → info[Reporter.Message.Profiling]
 ○ [0.000243s] Parse trees

 → info[Reporter.Message.Profiling]
 ○ [0.000044s] Read assets

Fatal error: exception Unhandled asai effect/exception; use Reporter.run
Raised at Stdlib__Effect.Deep.try_with.(fun) in file "effect.ml", line 101, characters 47-54
Called from Eio_unix__Thread_pool.run in file "lib_eio/unix/thread_pool.ml", line 108, characters 8-13
Re-raised at Eio_unix__Thread_pool.run in file "lib_eio/unix/thread_pool.ml", line 113, characters 4-39
Called from Eio_linux__Sched.run.(fun) in file "lib_eio_linux/sched.ml", line 498, characters 22-90
Re-raised at Eio_linux__Sched.run in file "lib_eio_linux/sched.ml", line 509, characters 22-57
Called from Eio_linux__Sched.with_eventfd in file "lib_eio_linux/sched.ml", line 536, characters 8-18
Re-raised at Eio_linux__Sched.with_eventfd in file "lib_eio_linux/sched.ml", line 541, characters 4-39
Called from Eio_linux__Sched.with_sched in file "lib_eio_linux/sched.ml", lines 570-572, characters 8-109
Re-raised at Eio_linux__Sched.with_sched in file "lib_eio_linux/sched.ml", line 583, characters 8-43
Called from Forester_prelude__Fun_util.let@ in file "lib/prelude/Fun_util.ml" (inlined), line 7, characters 13-19
Called from Dune__exe__Main in file "bin/forester/main.ml", lines 293-295, characters 2-44
```

The Reporter effect isn't being handled here (note that the `\import{index}` line is crucial to triggering the bug).

Here is a patch which fixes the issue:

```diff
diff --git a/lib/frontend/Forest_reader.ml b/lib/frontend/Forest_reader.ml
index b048794..ac840c6 100644
--- a/lib/frontend/Forest_reader.ml
+++ b/lib/frontend/Forest_reader.ml
@@ -52,6 +52,7 @@ module Eval_runner = struct
  let plus o1 o2 = { articles = o1.articles @ o2.articles; jobs = o1.jobs @ o2.jobs }

  let eval { host } (addr, source_path, syn) =
    Reporter.easy_run @@ fun () ->
    let iri = Iri_scheme.user_iri ~host addr in
    let result = Eval.eval_tree ~host ~iri ~source_path syn in
    { articles = result.main :: result.side; jobs = result.jobs }
```

The error is now the expected one:

```
 → info[Reporter.Message.Profiling]
○ [0.000244s] Parse trees

→ info[Reporter.Message.Profiling]
○ [0.000059s] Read assets

→ error[Reporter.Message.Type_error]
■ ./trees/new.tree
3 |   \foo#notexists
  ^ Expected object

```

I didn't submit this as a patch to be applied as I think this may be a symptom of a deeper issue to do with imports and evaluation (I didn't investigate further).

Kind regards,
Nick
Details
Message ID
<D5RVVSTNBD9A.31OUHEIJIPVKX@gmail.com>
In-Reply-To
<D5RUW5E8OO4T.1C2E4PPPN8D02@cs.ox.ac.uk> (view parent)
DKIM signature
pass
Download raw message
Hi Nick, thanks for the report.

I recently made some major changes to the way diagnostics are handled
internally. I have not yet pushed those changes, but the gist of it is
that diagnostics will be accumulated for each compilation phase so that
we can decide which errors to display towards the end of the compilation
run. It turns out that the error you reported does not occur for me when
using the new infrastructure, but is not reported at all (incidentally,
it is reported in the lsp). I will track this down and fix it.

Best, Kento

> (Apologies if you get multiple copies of this bug report, I tried
> sending it directly to ~jonsterling/forester@todo.sr.ht but for whatever
> reason that didn't work.)

I never tried to create a todo by mail, but responding has worked for
me...
Details
Message ID
<1d845269-a02e-49dc-83db-1f34f8ce0c67@app.fastmail.com>
In-Reply-To
<D5RUW5E8OO4T.1C2E4PPPN8D02@cs.ox.ac.uk> (view parent)
DKIM signature
pass
Download raw message
On Thu, Nov 21, 2024, at 12:30 PM, Nick Hu wrote:
> (Apologies if you get multiple copies of this bug report, I tried
> sending it directly to ~jonsterling/forester@todo.sr.ht but for whatever
> reason that didn't work.)


Hi Nick,

Can you please open a ticket using the web interface here? 
https://todo.sr.ht/~jonsterling/forester.

I will have to investigate a bit to determine the correct way to 
fix the bug you have identified.

Thanks,
Jon
Details
Message ID
<D5RW3UOL795U.2XISX8PUC2OXX@gmail.com>
In-Reply-To
<1d845269-a02e-49dc-83db-1f34f8ce0c67@app.fastmail.com> (view parent)
DKIM signature
pass
Download raw message
I have now fixed this locally using the new diagnostic infrastructure.

Best, Kento

On Thu Nov 21, 2024 at 2:16 PM CET, Jon Sterling wrote:
>
> On Thu, Nov 21, 2024, at 12:30 PM, Nick Hu wrote:
> > (Apologies if you get multiple copies of this bug report, I tried
> > sending it directly to ~jonsterling/forester@todo.sr.ht but for whatever
> > reason that didn't work.)
>
>
> Hi Nick,
>
> Can you please open a ticket using the web interface here? 
> https://todo.sr.ht/~jonsterling/forester.
>
> I will have to investigate a bit to determine the correct way to 
> fix the bug you have identified.
>
> Thanks,
> Jon
Reply to thread Export thread (mbox)