~technomancy/fennel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH fennel 0/1] Add file name to source maps

~equa
Details
Message ID
<161202505828.1225.4980910628885879111-0@git.sr.ht>
DKIM signature
missing
Download raw message
I'd appreciate some more testing on this. I think i've tested all of the
use cases but it'd be a very unfortunate experience to get an error
while generating tracebacks.

equa (1):
  Add file name to source maps

 src/fennel/compiler.fnl | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

-- 
2.26.2

[PATCH fennel 1/1] Add file name to source maps

~equa
Details
Message ID
<161202505828.1225.4980910628885879111-1@git.sr.ht>
In-Reply-To
<161202505828.1225.4980910628885879111-0@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
Patch: +13 -8
From: equa <equaa@protonmail.com>

This allows for proper line numbering when expanding macros, for
example, whereas previously tracebacks would produce the line number
of the macro source but the file name of the invocation.
---
 src/fennel/compiler.fnl | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/fennel/compiler.fnl b/src/fennel/compiler.fnl
index 09be556..4f66edb 100644
--- a/src/fennel/compiler.fnl
+++ b/src/fennel/compiler.fnl
@@ -260,7 +260,10 @@ Tab is what is used to indent a block."
      (let [code chunk.leaf
            info chunk.ast]
        (when sm
          (table.insert sm (or (and info info.line) (- 1))))
          (table.insert
            sm
            [(and info info.filename)
             (and info info.line)]))
        code)
      (let [tab (match tab
                  true "  " false "" tab tab nil "")]
@@ -293,8 +296,8 @@ Tab is what is used to indent a block."
        (let [sm []
              ret (flatten-chunk sm chunk options.indent 0)]
          (when sm
            (set sm.short_src (make-short-src (or options.filename
                                                  options.source ret)))
            (set sm.short_src (or options.filename
                                  (make-short-src (or options.source ret))))
            (set sm.key (if options.filename (.. "@" options.filename) ret))
            (tset fennel-sourcemap sm.key sm))
          (values ret sm)))))
@@ -777,16 +780,18 @@ which we have to do if we don't know."
      (let [remap (. fennel-sourcemap info.source)]
        (when (and remap (. remap info.currentline))
          ;; And some global info
          (set info.short-src remap.short-src)
          (set info.short_src
               (if (. remap info.currentline 1)
                   (. fennel-sourcemap (.. "@" (. remap info.currentline 1))
                      :short_src)
                   remap.short_src))
          ;; Overwrite info with values from the mapping
          ;; (mapping is now just integer, but may
          ;; eventually be a table)
          (set info.currentline (. remap info.currentline)))
          (set info.currentline (or (. remap info.currentline 2) -1)))
        (if (= info.what "Lua")
            (string.format "  %s:%d: in function %s"
                           info.short_src info.currentline
               (if info.name (.. "'" info.name "'") "?"))
            (= info.short-src "(tail call)")
            (= info.short_src "(tail call)")
            "  (tail call)"
            (string.format "  %s:%d: in main chunk"
                           info.short_src info.currentline)))))
-- 
2.26.2

[fennel/patches/.build.yml] build failed

builds.sr.ht
Details
Message ID
<C8WN75311ZEN.2GSK440K0YD40@cirno2>
In-Reply-To
<161202505828.1225.4980910628885879111-1@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
fennel/patches/.build.yml: FAILED in 17s

[Add file name to source maps][0] from [~equa][1]

[0]: https://lists.sr.ht/~technomancy/fennel/patches/19908
[1]: mailto:equaa@protonmail.com

✗ #411684 FAILED fennel/patches/.build.yml https://builds.sr.ht/~technomancy/job/411684

Re: [PATCH fennel 1/1] Add file name to source maps

Details
Message ID
<87bld5yr3y.fsf@whirlwind>
In-Reply-To
<161202505828.1225.4980910628885879111-1@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
~equa <equa@git.sr.ht> writes:
> This allows for proper line numbering when expanding macros, for
> example, whereas previously tracebacks would produce the line number
> of the macro source but the file name of the invocation.

Thanks! This is a really old chunk of code from the compiler that I
have never taken the opportunity to examine thoroughly. It sounds like
the problem was that previously the sourcemap assumed every AST in a
given chunk came from the same file, which was only true back before we
had a macro system.

Looks like this does the job! Thanks for taking the time to dig in.

-Phil
Reply to thread Export thread (mbox)