~sircmpwn/hare-users

6 2

hare build: Print paths relative to current working directory

Details
Message ID
<CWQ9IWWELP77.2TIL8M24VF5F5@mxsr.de>
DKIM signature
missing
Download raw message
Hi all,

when I run `hare build` in a project with dependencies, I get errors 
listed relative to the dependency project directories. Example:


$ cd ~/repos/rc
$ HAREPATH=/usr/local/src/hare/stdlib:/home/max/repos/madeline hare 
build -o rc cmd/rc/
0/7 tasks completed (0%)
made/actions.ha:85:53: error: Argument type []u8 is not assignable to parameter type const str
made/actions.ha:85:70: error: Argument type []u8 is not assignable to parameter type str

made harec exited with status 1


Of course, I can find `made/actions.ha` in `~/repos/madeline` when I try 
all possible locations manually. But for example vim doesn't find it. 
When I run `make` directly in vim:

:let $HAREPATH='/usr/local/src/hare/stdlib:/home/max/repos/madeline'
:make

... vim tries to open made/actions.ha relative to my current working 
directory: `~/repos/rc`.

Don't you think it would make sense to print all paths relative to the 
current working directory? Or alternatively absolute paths, at least for 
files outside the current directory?

Best regards,
Max
Details
Message ID
<CWZ2LD2QLA0C.31PHR5NJVCHBT@d2evs.net>
In-Reply-To
<CWQ9IWWELP77.2TIL8M24VF5F5@mxsr.de> (view parent)
DKIM signature
missing
Download raw message
it started doing this as part of the fix for
https://todo.sr.ht/~sircmpwn/hare/877. that being said, i think that the
thing that'd make the most sense here is to strip the -M parameter in
aborts and $PWD in compiler error messages. feel free to send a patch
for this if you'd like
Details
Message ID
<CX84YJEZHWUZ.167YBNVRU3O9N@mxsr.de>
In-Reply-To
<CWZ2LD2QLA0C.31PHR5NJVCHBT@d2evs.net> (view parent)
DKIM signature
missing
Download raw message
On Wed Nov 15, 2023 at 4:37 AM CET, Ember Sawady wrote:
> it started doing this as part of the fix for
> https://todo.sr.ht/~sircmpwn/hare/877. that being said, i think that the
> thing that'd make the most sense here is to strip the -M parameter in
> aborts and $PWD in compiler error messages. feel free to send a patch
> for this if you'd like

I have created a patch:

https://lists.sr.ht/~sircmpwn/hare-dev/patches/47004

I'm not sure if I understood you correctly. In case of an abort, isn't 
it too late to strip the -M parameter!?

In this patch, I replace all absolute paths with paths relative to the 
current working directory (no condition). This means, modpath isn't used 
at all. Just comment on it if you want it changed.
Details
Message ID
<CX9XQUTN6P6X.NCYWQFHA0XPE@d2evs.net>
In-Reply-To
<CX84YJEZHWUZ.167YBNVRU3O9N@mxsr.de> (view parent)
DKIM signature
missing
Download raw message
On Sat Nov 25, 2023 at 7:22 PM UTC, Max Schillinger wrote:
> https://lists.sr.ht/~sircmpwn/hare-dev/patches/47004

this isn't quite what i'm looking for but thanks for taking the time to
write a patch :)

> I'm not sure if I understood you correctly. In case of an abort, isn't 
> it too late to strip the -M parameter!?

there are two contexts in which harec has to print out paths: when
generating abort messages, and when generating compile-time error
messages

for the former, i'd like to keep the behavior we have today (though not
necessarily the implementation), where the path is relative to -M:

$ cat main.ha
use fmt;
export fn main() void = fmt::printf("{")!: void;
$ hare run main.ha
Abort: fmt/iter.ha:218:14: Invalid format string (unterminated '{')

rather than eg. /path/to/hare/stdlib/fmt/iter.ha, or
../../stdlib/fmt/iter.ha

for the latter, i think we should just strip $PWD. so, error messages
for code under the current directory will be valid relative paths, and
error messages for eg. stdlib code will be valid absolute paths

does this make sense?
Details
Message ID
<CXAMZ3UMLYDL.396Z09YVPA17P@mxsr.de>
In-Reply-To
<CX9XQUTN6P6X.NCYWQFHA0XPE@d2evs.net> (view parent)
DKIM signature
missing
Download raw message
On Mon Nov 27, 2023 at 11:08 PM CET, Ember Sawady wrote:
> there are two contexts in which harec has to print out paths: when
> generating abort messages, and when generating compile-time error
> messages
>
> for the former, i'd like to keep the behavior we have today (though not
> necessarily the implementation), where the path is relative to -M:
>
> $ cat main.ha
> use fmt;
> export fn main() void = fmt::printf("{")!: void;
> $ hare run main.ha
> Abort: fmt/iter.ha:218:14: Invalid format string (unterminated '{')
>
> rather than eg. /path/to/hare/stdlib/fmt/iter.ha, or
> ../../stdlib/fmt/iter.ha
>
> for the latter, i think we should just strip $PWD. so, error messages
> for code under the current directory will be valid relative paths, and
> error messages for eg. stdlib code will be valid absolute paths
>
> does this make sense?

So far I didn't care about runtime errors (because I only want to 
compile inside vim but not run/test the software inside vim). My pain 
point is this use case: When I compile rc in vim (using `:make`) and 
there is an error in its dependency madeline (caused by myself), I want 
to jump to the error line. But the output looks like this:


:!make  2>&1| tee /tmp/nvim.max/lp9OCs/4
hare build -o rc cmd/rc/
made/line.ha:155:15: error: Expression with result 'never' may not be 
followed by additional expressions
harec for made (/home/max/repos/madeline/made) exited with status 1
make: *** [Makefile:16: rc] Fehler 255

(1 aus 1): Expression with result 'never' may not be followed by additional expressions


Now I can't jump to made/line.ha because this file does not exist in 
$PWD (/home/max/repos/rc). The output must be either 

/home/max/repos/madeline/made/line.ha:155:15: error: ...

or

../madeline/made/line.ha:155:15: error: ...

to be understood by vim. (And probably it's the same for Emacs or Visual 
Studio Code.)

Do you want to keep error locations relative to a dependency project 
(like madeline in this example)? If yes, what do you think about a 
flag/mode for "machine (=vim) readable" output?
Details
Message ID
<CXAWOPT6SX7K.3MY2T1FC8WBPR@d2evs.net>
In-Reply-To
<CXAMZ3UMLYDL.396Z09YVPA17P@mxsr.de> (view parent)
DKIM signature
missing
Download raw message
On Tue Nov 28, 2023 at 5:54 PM UTC, Max Schillinger wrote:
> On Mon Nov 27, 2023 at 11:08 PM CET, Ember Sawady wrote:
> > there are two contexts in which harec has to print out paths: when
> > generating abort messages, and when generating compile-time error
> > messages
> >
> > for the former, i'd like to keep the behavior we have today (though not
> > necessarily the implementation), where the path is relative to -M:
> >
> > $ cat main.ha
> > use fmt;
> > export fn main() void = fmt::printf("{")!: void;
> > $ hare run main.ha
> > Abort: fmt/iter.ha:218:14: Invalid format string (unterminated '{')
> >
> > rather than eg. /path/to/hare/stdlib/fmt/iter.ha, or
> > ../../stdlib/fmt/iter.ha
> >
> > for the latter, i think we should just strip $PWD. so, error messages
> > for code under the current directory will be valid relative paths, and
> > error messages for eg. stdlib code will be valid absolute paths
> >
> > does this make sense?
>
> So far I didn't care about runtime errors (because I only want to 
> compile inside vim but not run/test the software inside vim). My pain 
> point is this use case: When I compile rc in vim (using `:make`) and 
> there is an error in its dependency madeline (caused by myself), I want 
> to jump to the error line. But the output looks like this:

the reason i brought runtime errors up is because your patch also
affects them, and i'd like to see a solution which keeps them as they
currently are

i think the way to do this that would work best would probably be to
keep paths absolute in the sources array, and strip either $PWD or the
-M argument in the various functions that emit locations
Details
Message ID
<CXCH3YMEZEQL.1F88JG27S0E8V@mxsr.de>
In-Reply-To
<CXAWOPT6SX7K.3MY2T1FC8WBPR@d2evs.net> (view parent)
DKIM signature
missing
Download raw message
On Wed Nov 29, 2023 at 2:31 AM CET, Ember Sawady wrote:
> > So far I didn't care about runtime errors (because I only want to 
> > compile inside vim but not run/test the software inside vim). My 
> > pain point is this use case: When I compile rc in vim (using 
> > `:make`) and there is an error in its dependency madeline (caused by 
> > myself), I want to jump to the error line. But the output looks like 
> > this:
>
> the reason i brought runtime errors up is because your patch also
> affects them, and i'd like to see a solution which keeps them as they
> currently are

OK, now I get it.

> i think the way to do this that would work best would probably be to
> keep paths absolute in the sources array, and strip either $PWD or the
> -M argument in the various functions that emit locations

True, this sounds much easier. I'll try to get it right in a new patch.
Reply to thread Export thread (mbox)