Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backtrace for test built-in reports wrong line number #6350

Closed
ammgws opened this issue Nov 25, 2019 · 3 comments
Closed

Backtrace for test built-in reports wrong line number #6350

ammgws opened this issue Nov 25, 2019 · 3 comments
Labels
bug
Milestone

Comments

@ammgws
Copy link
Contributor

@ammgws ammgws commented Nov 25, 2019

A bug (empty variable not quoted) in the fisher plugin done caused fish to show a backtrace, however the line numbers were off by a factor of two or so.

done is a script that displays notifications after long-running tasks finish, in the output below it has run after a pacman system update:

(6/7) Updating the desktop file MIME type cache...
(7/7) etckeeper: post-transaction commit
Parsing man pages and writing completions to /home/ammgws/.local/share/fish/generated_completions/
  4112 / 4112 : zramctl.8.gz                                        
test: Missing argument at index 2

~/.config/fish/conf.d/done.fish (line 88): 
	if test $__done_initial_window_id != (__done_get_focused_window_id)
	  ^
in function '__done_is_process_window_focused'
	called on line 152 of file ~/.config/fish/conf.d/done.fish
in function '__done_ended'
in event handler: handler for generic event “fish_prompt”

(Type 'help test' for related documentation)

Fish reports line 88, however the actual line is on line 45 (if start counting from 1).
Fish also reports line 152, however the actual line looks to be line 80.

fish: version 3.0.2-1833-g80a4898e7
terminal: kitty 0.14.6
OS: Arch Linux 5.3.12

Haven't tried without third-party customisations yet since trying to figure out how to reproduce the issue.

@faho
Copy link
Member

@faho faho commented Nov 25, 2019

Yeah, can reproduce with an event handler, but the test isn't actually necessary, because it's an issue in our line number counting.

#
# 
# some comments
# some more comments

function t --on-event fish_prompt
    status line-number
end

The line number will be the real line number times two, minus one. So if it's on line 5 you'll get line 9 reported.

@faho faho added the bug label Nov 25, 2019
@faho faho added this to the fish 3.1.0 milestone Nov 25, 2019
@faho
Copy link
Member

@faho faho commented Nov 25, 2019

Okay, this also needs to be done interactively. That means either in conf.d or config.fish. It also happens in 3.0.2.

@sniperrifle2004
Copy link

@sniperrifle2004 sniperrifle2004 commented Nov 25, 2019

Based on the examples given and a quick look at the relevant code it seems to me that it is because the parser adds the function definition line number to the line number from the execution context in get_lineno(). It's easy to fix, but it is hard to say whether this would break other cases in which this would actually be necessary.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug
Projects
None yet
Development

No branches or pull requests

3 participants