• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

google / go-jsonnet / 13996614558
56%
master: 44%

Build:
Build:
LAST BUILD BRANCH: error-test-for-manifestYamlDoc
DEFAULT BRANCH: master
Ran 21 Mar 2025 04:45PM UTC
Jobs 1
Files 65
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

21 Mar 2025 04:37PM UTC coverage: 55.582% (+0.008%) from 55.574%
13996614558

Pull #797

github

johnbartholomew
fix: Fix error messages when a comprehension iterates over a non-array.

Problems:
 - When iterating over an empty string in a list comprehension, the
   result is an empty string. This is a bug, it should be an error.
 - When iterating over a non-empty string in a list comprehension, the
   expected and unexpected types in the error message are swapped.
 - Error messages mention "std.flatMap" when object/list comprehensions
   would iterate over a value that is neither array nor string.

```
$ jsonnet --version
Jsonnet commandline interpreter (Go implementation) v0.21.0-rc2
$ jsonnet -e '[a for a in ""]'
""
$ jsonnet -e '[a for a in "b"]'
RUNTIME ERROR: Unexpected type array, expected string
	<cmdline>:1:1-17
	During evaluation
$ jsonnet -e '{[a]: 1 for a in 2}'
RUNTIME ERROR: std.flatMap second param must be array / string, got number
	<cmdline>:1:1-20
	<cmdline>:1:1-20
	During evaluation
$ jsonnet -e '[a for a in 1]'
RUNTIME ERROR: std.flatMap second param must be array / string, got number
	<cmdline>:1:1-15
	During evaluation
```

FWIW, the C++ implementation does not have any of these problems. It
gives:
```
RUNTIME ERROR: In comprehension, can only iterate over array.
```

In the Go implementation comprehensions are desugared to a call to
std.flatMap which does accept a string in the "arr" parameter.

The fix: Desugar comprehensions to a call to a new hidden builtin which
only accepts arrays.
Pull Request #797: fix: Fix error messages when a comprehension iterates over a non-array.

7 of 8 new or added lines in 3 files covered. (87.5%)

2 existing lines in 1 file now uncovered.

7558 of 13598 relevant lines covered (55.58%)

185178.06 hits per line

New Missed Lines in Diff

Lines Coverage ∆ File
1
0.0
0.0% internal/program/desugarer.go

Uncovered Existing Lines

Lines Coverage ∆ File
2
80.74
-0.04% builtins.go
Jobs
ID Job ID Ran Files Coverage
1 13996614558.1 21 Mar 2025 04:45PM UTC 65
55.58
GitHub Action Run
Source Files on build 13996614558
  • Tree
  • List 65
  • Changed 2
  • Source Changed 0
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Pull Request #797
  • PR Base - master (#13885446470)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc