|
| 1 | +;; (map K V) validation |
| 2 | + |
| 3 | +(component definition |
| 4 | + (type (map bool u8)) |
| 5 | + (type (map s8 u8)) |
| 6 | + (type (map u8 u8)) |
| 7 | + (type (map s16 u8)) |
| 8 | + (type (map u16 u8)) |
| 9 | + (type (map s32 u8)) |
| 10 | + (type (map u32 u8)) |
| 11 | + (type (map s64 u8)) |
| 12 | + (type (map u64 u8)) |
| 13 | + (type (map char u8)) |
| 14 | + (type (map string u8)) |
| 15 | + (type (map string f64)) |
| 16 | + (type (map string string)) |
| 17 | + (type (map string (list u8))) |
| 18 | + (type (map string (tuple u8 string))) |
| 19 | + (type (map string (record (field "a" u32) (field "b" string)))) |
| 20 | + (type (map string (variant (case "a") (case "b" u32)))) |
| 21 | + (type (map string (enum "x" "y"))) |
| 22 | + (type (map string (flags "p" "q"))) |
| 23 | + (type (map string (option string))) |
| 24 | + (type (map string (result u32 (error string)))) |
| 25 | + (type (map string (map u32 (list string)))) |
| 26 | + (type (list (map string u32))) |
| 27 | + (type (option (map u32 string))) |
| 28 | + (type (stream (map string u32))) |
| 29 | + (type (future (map string u32))) |
| 30 | + (type (func (param "m" (map string u32)) (result (map u32 string)))) |
| 31 | +) |
| 32 | + |
| 33 | +(assert_invalid |
| 34 | + (component (type (map f32 u8))) |
| 35 | + "invalid map key type") |
| 36 | +(assert_invalid |
| 37 | + (component (type (map (list u8) u8))) |
| 38 | + "invalid map key type") |
| 39 | +(assert_invalid |
| 40 | + (component (type (map (tuple u8 u8) u8))) |
| 41 | + "invalid map key type") |
| 42 | +(assert_invalid |
| 43 | + (component |
| 44 | + (type $R (resource (rep i32))) |
| 45 | + (type (map (own $R) u8))) |
| 46 | + "invalid map key type") |
| 47 | +(assert_invalid |
| 48 | + (component |
| 49 | + (type $R (resource (rep i32))) |
| 50 | + (type (map u32 (own $R)))) |
| 51 | + "map value type cannot contain a handle") |
| 52 | +(assert_invalid |
| 53 | + (component |
| 54 | + (type $R (resource (rep i32))) |
| 55 | + (type (map string (option (borrow $R))))) |
| 56 | + "map value type cannot contain a handle") |
| 57 | +(assert_invalid |
| 58 | + (component |
| 59 | + (type (map string (record (field "f" (future u8)))))) |
| 60 | + "map value type cannot contain a handle") |
| 61 | +(assert_invalid |
| 62 | + (component |
| 63 | + (type (map u8 (list (stream u8))))) |
| 64 | + "map value type cannot contain a handle") |
| 65 | +(assert_invalid |
| 66 | + (component |
| 67 | + (type $FT (future)) |
| 68 | + (type (map char (variant (case "a") (case "b" $FT))))) |
| 69 | + "map value type cannot contain a handle") |
| 70 | +(assert_invalid |
| 71 | + (component |
| 72 | + (type $R (resource (rep i32))) |
| 73 | + (type $Rec (record (field "r" (own $R)))) |
| 74 | + (type (map u32 $Rec))) |
| 75 | + "map value type cannot contain a handle") |
| 76 | +(assert_invalid |
| 77 | + (component |
| 78 | + (type $R (resource (rep i32))) |
| 79 | + (type (map string (map string (tuple u32 (own $R)))))) |
| 80 | + "map value type cannot contain a handle") |
| 81 | +(assert_invalid |
| 82 | + (component |
| 83 | + (import "r" (type $R (sub resource))) |
| 84 | + (import "f" (func (param "m" (map string (own $R)))))) |
| 85 | + "map value type cannot contain a handle") |
0 commit comments