Skip to content

Commit 7dbb8be

Browse files
committed
fixed tuples with nulls
1 parent 92e449e commit 7dbb8be

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/org/rascalmpl/library/lang/json/internal/JsonValueReader.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ public IValue visitString(Type type) throws IOException {
160160
return vf.string(nextString());
161161
}
162162

163-
@Override
164-
public IValue visitTuple(Type type) throws IOException {
165-
if (isNull()) {
166-
return null;
167-
}
163+
@Override
164+
public IValue visitTuple(Type type) throws IOException {
165+
if (isNull()) {
166+
return null;
167+
}
168168

169169
List<IValue> l = new ArrayList<>();
170170
in.beginArray();
@@ -183,7 +183,13 @@ public IValue visitTuple(Type type) throws IOException {
183183
in.endArray();
184184

185185
// filter all the null values
186-
l.removeIf(p -> p == null);
186+
l.forEach(e -> {
187+
if (e == null) {
188+
throw parseErrorHere("Tuples can not have null elements.");
189+
}
190+
});
191+
192+
assert type.getArity() == l.size();
187193

188194
return vf.tuple(l.toArray(new IValue[l.size()]));
189195
}

src/org/rascalmpl/library/lang/rascal/tests/library/lang/json/JSONIOTests.rsc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ test bool dealWithNull() {
210210

211211
// test different specific nulls for different expected types:
212212
for (t <- defaultJSONNULLValues<0>) {
213-
println(t);
214213
assert parseJSON(t, "null") == (defaultJSONNULLValues[t]?"default-not-found");
215214
}
216215

0 commit comments

Comments
 (0)