Skip to content

Commit

Permalink
fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuf239 committed Aug 7, 2024
1 parent 060fa96 commit 0771fe4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
14 changes: 14 additions & 0 deletions examples/tests/invalid/json_values.test.w
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
let arr = MutArray<num>[1, 2, 3];
arr.push(4);

let map = MutMap<str>{"a" => "1"};
map.set("b", "2");

let takeJson = (obj: Json) => {

};

takeJson({ values: arr });
// ^^^^^^^^^^^^^^^ "MutArray<num>" is not a legal JSON value
takeJson({ values: map });
// ^^^^^^^^^^^^^^^ "MutMap<str>" is not a legal JSON value
14 changes: 0 additions & 14 deletions examples/tests/valid/json-types.test.w
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


let extra = MutArray<Json>["bar"];
let base = [Json "foo"];
base.concat(extra.copy());
Expand All @@ -11,15 +9,3 @@ let obj = {
second: ["cool"].concat(base2)
};

let arr = MutArray<num>[1, 2, 3];
arr.push(4);

let map = MutMap<str>{"a" => "1"};
map.set("b", "2");

let takeJson = (obj: Json) => {

};

takeJson({ values: arr });
takeJson({ values: map });
2 changes: 0 additions & 2 deletions libs/wingc/src/type_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,9 +1276,7 @@ impl TypeRef {
Type::Boolean => true,
Type::MutJson | Type::Json(None) => true,
Type::Inferred(..) => true,
Type::MutArray(v) => v.is_json_legal_value(),
Type::Array(v) => v.is_json_legal_value(),
Type::MutMap(v) => v.is_json_legal_value(),
Type::Map(v) => v.is_json_legal_value(),
Type::Struct(ref s) => {
for t in s.fields(true).map(|(_, v)| v.type_) {
Expand Down

0 comments on commit 0771fe4

Please sign in to comment.