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

google / go-jsonnet
56%
master: 44%

Build:
Build:
LAST BUILD BRANCH: error-test-for-manifestYamlDoc
DEFAULT BRANCH: master
Repo Added 21 Feb 2016 05:23PM UTC
Files 65
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

LAST BUILD ON BRANCH rudo-fix-comprehension-over-string-error-message
branch: rudo-fix-comprehension-over-string-error-message
CHANGE BRANCH
x
Reset
  • rudo-fix-comprehension-over-string-error-message
  • bazelfixes
  • bazelisk
  • bugfix/setuptools-72
  • build_cleanup
  • error-test-for-manifestYamlDoc
  • feat/csv
  • fix-manifestYamlDoc-error-check
  • fix-minArray-maxArray-keyF
  • go-mod-version
  • master
  • mcarl/fix-oob-formatter
  • no-libjsonnet-h
  • prepare-release
  • python-release-gil
  • pywheels
  • readme-updates
  • update-ci
  • update-cpp-script
  • update-dependencies
  • update-go-deps
  • update-project-status
  • v0.10.0
  • v0.16.0
  • v0.17.0

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

Relevant lines Covered
Build:
Build:
13598 RELEVANT LINES 7558 COVERED LINES
185178.06 HITS PER LINE
Source Files on rudo-fix-comprehension-over-string-error-message
  • Tree
  • List 65
  • Changed 2
  • Source Changed 0
  • Coverage Changed 2
Coverage ∆ File Lines Relevant Covered Missed Hits/Line

Recent builds

Builds Branch Commit Type Ran Committer Via Coverage
13996614558 rudo-fix-comprehension-over-string-error-message 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... Pull #797 21 Mar 2025 04:45PM UTC johnbartholomew github
55.58
13855246391 rudo-fix-comprehension-over-string-error-message 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... Pull #797 21 Mar 2025 04:29PM UTC rudo-thomas github
55.58
See All Builds (1239)
  • Repo on GitHub
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