I understand it this way:
The implicit return
gets inserted by the interpreter at runtime as an extra line, not on the same line as the hotkey one-liner.
reclaims it as its second line. That is very unfortunate, but perhaps not technically a bug.
Although I would also prefer that one-liner hotkeys wouldn't allow two-liner If-statements at all. On the other hand, I would have never tried it, because the docs say:
For me, that means implicitly
, that two-line constructions like non-traditional If
cannot be used with it.
Turns out, it can be used, but not really in a useful way.
(What happens if you still do it, is not explicitly
defined in the docs)
swagfag wrote: ↑
10 Oct 2019, 02:47
reports the return
on the same line:
As I understand it, Listlines
and error messages report implicit returns on the line number that causes
to be inserted.
But the implicit return line is de facto
handled as an extra line.
If Listlines would report the implicit return with an additional line number, all others line number after it would shift and that would create problems for the user while debugging - the line numbers wouldn't match anymore with the actual source code in the editor.
As I've shown in the german thread, the implicit return at the end of an auto-execute section
also gets reported on the line number of the hotkey that is responsible for it, although syntactically
it wouldn't make sense to have a return and a hotkey label/defintion on the same line.
If you run this code and then press first 1
and then 2
Code: Select all
x := "" ; 001
1::MsgBox ; 003
2::Listlines ; 004
you will get this result in the ListLines
Code: Select all
001: x := ""
003: Return (1.47)
003: MsgBox (0.91)
003: Return (0.38)
The first return that is reported on line 003 is the implicit return of the auto-execute section (only at script start). It for sure gets treated as a single line by the interpreter. Otherwise, the hotkey defintion on the same line would throw an error message.
The second implicit return gets also reported on the line that caused
it (again 003), allowing to keep the original line numbers for all following lines.
I think if you report line numbers for implicit returns at all, this is probably still the best way to do it. (I think, it's helpful.)