walt-compiler
Version:
Alternative syntax for WebAssembly text format
317 lines (269 loc) • 7.44 kB
Markdown
# Snapshot report for `src/validation/__tests__/validation-spec.js`
The actual snapshot is saved in `validation-spec.js.snap`.
Generated by [AVA](https://ava.li).
## access on undefined objects
> Snapshot 1
Error {
message: `Cannot generate WebAssembly for spec.walt. 1 problems.␊
␊
␊
obj.y = 5;␊
^ Cannot assign "5". Key is "unreachable"␊
Cannot generate property access␊
at test() (spec.walt:3:12)␊
`,
}
## ast must have metadata attached
> Snapshot 1
Error {
message: 'Missing AST metadata!',
}
## const cannot be re-asigned
> Snapshot 1
Error {
message: `Cannot generate WebAssembly for spec.walt. 2 problems.␊
␊
␊
x = 1;␊
const variables cannot be reassigned, use let instead.␊
Cannot reassign a const variable x␊
at test() (spec.walt:4:12)␊
␊
␊
y += 1;␊
const variables cannot be reassigned, use let instead.␊
Cannot reassign a const variable y␊
at test() (spec.walt:6:13)␊
`,
}
## constants must be initialized
> Snapshot 1
Error {
offset: 13,
token: {
col: 22,
line: 2,
lineBreaks: 0,
offset: 22,
text: '+',
toString: Function tokenToString {},
type: 'punctuator',
value: '+',
},
message: `undefined at line 2 col 22:␊
␊
const g: i32 = 2 +␊
^␊
Unexpected punctuator token: "+"␊
`,
}
## functions must be defined
> Snapshot 1
Error {
message: `Cannot generate WebAssembly for spec.walt. 4 problems.␊
␊
␊
const ptr: Type = 0;␊
Variables must be assigned with a known type.␊
Unknown type used in a declartion, "Type"␊
at test() (spec.walt:3:27)␊
␊
␊
ptr();␊
^ ptr has type Type which is not defined. Indirect calls must have pre-defined types.␊
Cannot make an indirect call without a valid function type␊
at test() (spec.walt:4:12)␊
␊
␊
return notDefined();␊
^^^^^^^^ notDefined is not defined.␊
Undefined function reference␊
at test() (spec.walt:5:26)␊
␊
␊
return notDefined();␊
^^^^^^^ Inconsistent return value. Expected i32 received null␊
Missing return value␊
at test() (spec.walt:5:27)␊
`,
}
## functions must have consistent returns
> Snapshot 1
Error {
message: `Cannot generate WebAssembly for spec.walt. 2 problems.␊
␊
␊
return;␊
Inconsistent return value. Expected i32 received null␊
Missing return value␊
at i32void() (spec.walt:3:14)␊
␊
␊
return x;␊
Inconsistent return value. Expected i32 received i64␊
Missing return value␊
at i32i64() (spec.walt:7:16)␊
`,
}
## global exports must have value
> Snapshot 1
Error {
offset: 8,
token: {
col: 20,
line: 1,
lineBreaks: 0,
offset: 19,
text: ';',
toString: Function tokenToString {},
type: 'punctuator',
value: ';',
},
message: `undefined at line 1 col 20:␊
␊
export const x: i32;␊
^␊
Unexpected punctuator token: ";"␊
`,
}
## invalid sucbscript target
> Snapshot 1
Error {
message: `Cannot generate WebAssembly for spec.walt. 1 problems.␊
␊
␊
v += a[i];␊
Expected array type for a, received i32␊
Invalid subscript target␊
at fn() (spec.walt:11:12)␊
`,
}
## typos throw
> Snapshot 1
Error {
offset: 0,
token: {
col: 1,
line: 1,
lineBreaks: 0,
offset: 0,
text: 'expost',
toString: Function tokenToString {},
type: 'identifier',
value: 'expost',
},
message: `undefined at line 1 col 1:␊
␊
expost␊
^␊
Unexpected identifier token: "expost"␊
`,
}
## undefined object properties
> Snapshot 1
Error {
message: `Cannot generate WebAssembly for spec.walt. 3 problems.␊
␊
␊
y = obj.y;␊
^ Cannot assign "unreachable". Key is "unreachable"␊
Cannot generate property access␊
at test() (spec.walt:6:16)␊
␊
␊
obj = { y: 5 };␊
^ Cannot assign "5". Key is "unreachable"␊
Cannot generate property access␊
at test() (spec.walt:7:16)␊
␊
␊
obj.y = 5;␊
^ Cannot assign "5". Key is "unreachable"␊
Cannot generate property access␊
at test() (spec.walt:8:12)␊
`,
}
## undefined types throw
> Snapshot 1
Error {
message: `Cannot generate WebAssembly for spec.walt. 1 problems.␊
␊
␊
import { foo: Type } from 'env';␊
^^^^ Invalid Import. Type type does not exist␊
Undefined Type Type␊
at global (spec.walt:1:19)␊
`,
}
## unknown user types at global scope, error
> Snapshot 1
Error {
message: `Cannot generate WebAssembly for spec.walt. 2 problems.␊
␊
␊
let t: unknown = 0;␊
Variables must be assigned with a known type.␊
Unknown type used in a declaration, "unknown"␊
at global (spec.walt:2:24)␊
␊
␊
let k: unknown = 0;␊
Variables must be assigned with a known type.␊
Unknown type used in a declartion, "unknown"␊
at foo() (spec.walt:4:26)␊
`,
}
## unterminated assignment statements
> Snapshot 1
Error {
offset: 44,
token: {
col: 7,
line: 6,
lineBreaks: 0,
offset: 85,
text: 'y',
toString: Function tokenToString {},
type: 'identifier',
value: 'y',
},
message: `undefined at line 6 col 7:␊
␊
y␊
^␊
Unexpected identifier token: "y"␊
`,
}
## unterminated declaration statements
> Snapshot 1
Error {
offset: 23,
token: {
col: 7,
line: 4,
lineBreaks: 0,
offset: 52,
text: 'x',
toString: Function tokenToString {},
type: 'identifier',
value: 'x',
},
message: `undefined at line 4 col 7:␊
␊
x␊
^␊
Unexpected identifier token: "x"␊
`,
}
## untyped imports need to be compiled out via a linker/build step
> Snapshot 1
Error {
message: `Cannot generate WebAssembly for spec.walt. 1 problems.␊
␊
␊
foo␊
^^^ Looks like you'd like to infer a type, but it was never provided by a linker. Non-concrete types cannot be compiled.␊
Infered type not supplied.␊
at global (spec.walt:3:10)␊
`,
}