-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
What should '. |= try . catch .' do in jq 1.6, and why is it different from jq 1.5? #2011
Comments
This... does seem incorrect. I'll see what I can figure out. |
The behavior change would have been introduced here: bd7b48c It's a weird interaction of nesting labels and a try/catch that trips up a bug in the way we generate code for the The issue is that when we look for the internal errors jq uses to handle certain types of control flow jumps (in particular around labels), we intend to check for the type of the error to be an object, but instead we compare the error to "object". You can see this by running I'll push a fix later tonight. |
I pushed e74eab8, which fixes this. Thanks for the report! |
@wtlangford - Great work as always. Thanks. I thought it was time to recreate an instance of jq "from scratch" and sure enough ran into some issues. After the first failure, I installed pipenv (
I suppose I'm supposed to install somehow but pip3 says it's already installed:
Maybe I need to dig deeper into the (revised?) installation instructions, but I'm disappointed that what used to be a painless process has seemingly become somewhat fraught. Am I missing something? |
@pkoppstein- yeah, that's an issue I'm aware of. It also prevents people from doing |
That's... definitely not right. It shouldn't be running that at all, and
the necessary files shouldn't be present for it to be able to. Are you sure
you're on the right commit?
…On Thu, Nov 21, 2019 at 21:39 pkoppstein ***@***.***> wrote:
@wtlangford <https://github.com/wtlangford> - Thanks -- make completed
without too much fuss. For reference, ./jq --version reports:
jq-1.3-894-ga1f1231
If the dependencies on Ruby have been removed, it seems odd to see:
checking for Ruby dependencies... configure: WARNING: The following gems are missing
* rake (10.4.2)
* i18n (0.7.0)
* json (1.8.3)
* minitest (5.8.0)
* thread_safe (0.3.5)
* tzinfo (1.2.2)
* activesupport (4.2.3)
* addressable (2.3.8)
* builder (3.2.2)
* launchy (2.4.3)
* liquid (3.0.6)
* maruku (0.7.2)
* rack (1.6.4)
* sass (3.4.16)
* rack-protection (1.5.3)
* tilt (2.0.1)
* sinatra (1.4.6)
* watch (0.1.0)
* yui-compressor (0.12.0)
* bonsai (1.4.9)
* hpricot (0.8.6)
* mustache (0.99.8)
* rdiscount (2.1.8)
* ronn (0.7.3)
Install missing gems with `bundle install`
*****************************************************************
* Ruby dependencies for building jq documentation not found. *
* You can still build, install and hack on jq, but the manpage *
* will not be rebuilt and some of the tests will not run. *
* See docs/README.md for how to install the docs dependencies. *
*****************************************************************
------------------------------
The other warning messages of interest are as follows:
In file included from src/builtin.c:157:
src/libm.h:163:10: warning: 'drem' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
LIBM_DDD(drem)
^
/usr/include/math.h:755:15: note: 'drem' has been explicitly marked deprecated here
extern double drem(double, double) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_NA, __IPHONE_NA);
^
In file included from src/builtin.c:157:
src/libm.h:218:9: warning: 'gamma' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
LIBM_DD(gamma)
^
/usr/include/math.h:759:15: note: 'gamma' has been explicitly marked deprecated here
extern double gamma(double) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_NA, __IPHONE_NA);
^
In file included from src/builtin.c:157:
src/libm.h:278:9: warning: 'significand' is deprecated: first deprecated in macOS 10.9 [-Wdeprecated-declarations]
LIBM_DD(significand)
^
/usr/include/math.h:761:15: note: 'significand' has been explicitly marked deprecated here
extern double significand(double) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_NA, __IPHONE_NA);
^
src/builtin.c:194:31: warning: implicit declaration of function 'lgamma_r' is invalid in C99 [-Wimplicit-function-declaration]
jv ret = JV_ARRAY(jv_number(lgamma_r(jv_number_value(input), &sign)));
^
4 warnings generated.
CC src/lexer.lo
src/lexer.c:1500:47: warning: comparison of integers of different signs: 'int' and 'yy_size_t' (aka 'unsigned long')
[-Wsign-compare]
if ((int) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2011>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2DQVY6UBIMHOSJVOM2KI3QU5A6JANCNFSM4JN5Y4FA>
.
|
@wtlangford: Whoops - I just let SourceTree clone the repo without checking which branch it was checking out. So, after checking out the relevant version, things ran successfully for a while,
|
I'm surprised that branch is trying to force you to regen the manpage- it's
supposed to use the prebuilt version unless you've modified manpage.yml.
What's your `git show` say for the current commit?
…On Thu, Nov 21, 2019 at 22:24 pkoppstein ***@***.***> wrote:
@wtlangford <https://github.com/wtlangford>: Whoops - I just let
SourceTree clone the repo without checking which branch it was checking out.
So, after checking out the relevant version, things ran successfully for a
while,
but then the dreaded 'lxml' dragon raised its fearsome head:
....
checking for Python dependencies... Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Creating a virtualenv for this project…
...
✔ Successfully created virtual environment!
...
GEN jq.1
Traceback (most recent call last):
File "build_manpage.py", line 4, in <module>
from lxml import etree
ModuleNotFoundError: No module named 'lxml'
make[2]: *** [jq.1] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2011>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA2DQV73CCOAT22HYOEMVNDQU5GH3ANCNFSM4JN5Y4FA>
.
|
@wtlangford -
|
Close jqlang#1885, jqlang#2140, jqlang#2011, jqlang#2220, jqlang#2485, 2073 Rename the FORK_OPT opcode to TRY_BEGIN, add a TRY_END opcode, and wrap errors when raising through a TRY_END so that they will not be caught by the matching TRY_BEGIN. Now a `try exp catch handler` expression generates code like: TRY_BEGIN handler <exp> TRY_END JUMP past_handler handler: <handler> past_handler: ... On backtrack through TRY_BEGIN it just backtracks. If anything past the whole thing raises when <exp> produced a value, then the TRY_END will catch the error, wrap it in another, and backtrack. The TRY_BEGIN will see a wrapped error and then it will unwrap and re-raise the error. If <exp> raises, then TRY_BEGIN will catch the error and jump to the handler, but the TRY_BEGIN will not stack_save() in that case, so on raise/backtrack the TRY_BEGIN will not execute again (nor will the TRY_END).
Close #1885, #2140, #2011, #2220, #2485, #2073 Rename the FORK_OPT opcode to TRY_BEGIN, add a TRY_END opcode, and wrap errors when raising through a TRY_END so that they will not be caught by the matching TRY_BEGIN. Now a `try exp catch handler` expression generates code like: TRY_BEGIN handler <exp> TRY_END JUMP past_handler handler: <handler> past_handler: ... On backtrack through TRY_BEGIN it just backtracks. If anything past the whole thing raises when <exp> produced a value, then the TRY_END will catch the error, wrap it in another, and backtrack. The TRY_BEGIN will see a wrapped error and then it will unwrap and re-raise the error. If <exp> raises, then TRY_BEGIN will catch the error and jump to the handler, but the TRY_BEGIN will not stack_save() in that case, so on raise/backtrack the TRY_BEGIN will not execute again (nor will the TRY_END).
Describe the bug
Unless
|=
in combination withtry
-catch
have changed semantics, this is probably a bug?Update: I understand from #658 that
{"__jq": 0}
is some internal control mechanism.To Reproduce
See above or visit https://jqplay.org/s/M_RpdNHvHF for jq 1.6.
Expected behavior
Unless I'm mistaken, this should return
1
in both versions.Note that neither
. |= .
nortry . catch .
alone produce this effect.Environment (please complete the following information):
Additional context
Discovered here:
https://stackoverflow.com/questions/58879588/jq-try-catch-goes-directly-to-catch-even-when-no-error
The text was updated successfully, but these errors were encountered: