jqlang / jq

Command-line JSON processor
https://jqlang.github.io/jq/
Other
29.59k stars 1.54k forks source link

Including and importing module with importing JSON crashes jq #3126

Open 01mf02 opened 1 month ago

01mf02 commented 1 month ago

Suppose that we have two files:

# mod.jq
import "data" as $data;
.

# main.jq
import "mod" as mod;
include "mod";
.

Running jq -n -f main.jq yields:

jq: error: jq: error: library should only have function definitions, not a main expression
<unknown location>
jq-linux-amd64-1.7.1: src/compile.c:383: block_bind_library: Assertion `block_has_only_binders(binder, bindflags)' failed.
Aborted (core dumped)

The same also happens when we write twice import or include.

Environment