Hi! This is also reproducible in C6 CSI on linux.. Also if (1 2 3 4 5) slightly modified to (a 1 2 3 4 5), it works as expected. IMO in the syntax programming (get-line-number, read-with-source-info part of) all macrotech is about template (fname ...) substitution. Maybe the roots of such behavior of [read-with-source-info].
сб, 29 нояб. 2025 г. в 19:59, Alexey Egorov via Chicken-users < [email protected]>: > Hello. > I'm using Chicken 5.4.0. I tried to use read-with-source-info and got > quite strange results. Despite reading from file (by means of > with-input-from-file), subsequent calls to get-line-number report > input file as <stdin> or even #f. The following example demonstrates > the issue: > test.txt: > (a b c d e) > (1 2 3 4 5) > (a b c) > > main.scm: > (import (chicken base) > (chicken syntax)) > > (define (main) > (let ((forms > (with-input-from-file "./test.txt" > (lambda () > (let loop ((acc (list))) > (let ((r (read-with-source-info))) > (if (eof-object? r) > (reverse acc) > (loop (cons r acc))))))))) > (map (lambda (x) > (print x ":" (get-line-number x))) > forms) > (newline))) > > (main) > > The code was compiled like this: > csc main.scm -o main > > The program's output: > $ ./main > (a b c d e):<stdin>:1 > (1 2 3 4 5):#f > (a b c):<stdin>:3 > > The result is the same on both Linux and macOS. Replacing > (read-with-source-info) with explicit (read-with-source-info > (current-input-port)) doesn't change anything. > Searching the bugtracker didn't yield any results. Should I file a > report there, by the way? > Brief investigation hadn't produced any conclusion yet. Any help is > appreciated. > > One more thing, markup in the corresponding section of the manual is > evidently broken (on the wiki too: > https://wiki.call-cc.org/man/5/Module (chicken > syntax)#read-with-source-info/). > Here's the patch: > diff --git a/manual/Module (chicken syntax) b/manual/Module (chicken > syntax) > index 19e550be..48127201 100644 > --- a/manual/Module (chicken syntax) > +++ b/manual/Module (chicken syntax) > @@ -368,10 +368,10 @@ renamed. > > <procedure>(read-with-source-info [port])</procedure> > > -Exactly like {{{read}}} from the {{{scheme}}} module, except it > +Exactly like {{read}} from the {{scheme}} module, except it > registers the expression it read into the line number database, so > -that if {{{(read-with-source-info)}}} returns {{{OBJ}}}, > -{{{(get-line-number OBJ)}}} will return the line number in {{{port}}}. > +that if {{(read-with-source-info)}} returns {{OBJ}}, > +{{(get-line-number OBJ)}} will return the line number in {{port}}. > > The port argument may be omitted, in which case it defaults to the > value returned by {{current-input-port}}. It is an error to read from > > -- > Best regards. > Alexey Egorov. > >
