Open felix9 opened 2 weeks ago
Looking for the function is done in the compilation phase, and it is difficult (or making the code messy) to tell that the function is the right hand side of a binary expression which has indexing in the left hand side and .... Also can we know the difference between .last - name
and .last-name
in the compilation phase?
it looks to me like it wouldn't be too hard to add a heuristic check at the point of the error message. check if the source expression looks like unquoted skewer case, and suggest that might be the problem. I might have time/energy to write a POC patch this weekend
For context me and @felix9 talked a bit about this on mastodon https://fosstodon.org/@dkub@woof.group/113455083464066624 specially that there is two cases, a compile time and runtime time case, and probably the compile time case is more common and might be an easier case for heuristics?
If json keys are kebab case ("last-name"), it's natural to try something like
which emits a confusing error message:
this seems like a common enough problem that it might be worth making a special error message for expressions that look like that.
(alternatively, the jq language could support kebab-case literals. this might break some scripts, but it seems unlikely that anyone would deliberately write an expression that looks like kebab-case)