Improved type safety for memory writes
This commit is contained in:
@ -2,6 +2,6 @@ main() {
|
||||
writeToMemory(42)
|
||||
}
|
||||
|
||||
writeToMemory(p *any) {
|
||||
p[0] = 'A'
|
||||
writeToMemory(p *byte) {
|
||||
[p] = 'A'
|
||||
}
|
6
tests/errors/TypeMismatch6.q
Normal file
6
tests/errors/TypeMismatch6.q
Normal file
@ -0,0 +1,6 @@
|
||||
import mem
|
||||
|
||||
main() {
|
||||
a := mem.alloc(1)
|
||||
a[0] = int64(1)
|
||||
}
|
@ -49,11 +49,12 @@ var errs = []struct {
|
||||
{"MissingParameter3.q", errors.MissingParameter},
|
||||
{"MissingType.q", errors.MissingType},
|
||||
{"ReturnCountMismatch.q", &errors.ReturnCountMismatch{Count: 1, ExpectedCount: 0}},
|
||||
{"TypeMismatch.q", &errors.TypeMismatch{Expected: "*any", Encountered: "int", ParameterName: "p"}},
|
||||
{"TypeMismatch.q", &errors.TypeMismatch{Expected: "*uint8", Encountered: "int", ParameterName: "p"}},
|
||||
{"TypeMismatch2.q", &errors.TypeMismatch{Expected: "[]any", Encountered: "int", ParameterName: "array"}},
|
||||
{"TypeMismatch3.q", &errors.TypeMismatch{Expected: "int", Encountered: "[]uint8"}},
|
||||
{"TypeMismatch4.q", &errors.TypeMismatch{Expected: "int", Encountered: "[]uint8"}},
|
||||
{"TypeMismatch5.q", &errors.TypeMismatch{Expected: "*any", Encountered: "int64"}},
|
||||
{"TypeMismatch6.q", &errors.TypeMismatch{Expected: "uint8", Encountered: "int64"}},
|
||||
{"UnknownIdentifier.q", &errors.UnknownIdentifier{Name: "x"}},
|
||||
{"UnknownIdentifier2.q", &errors.UnknownIdentifier{Name: "x"}},
|
||||
{"UnknownIdentifier3.q", &errors.UnknownIdentifier{Name: "x"}},
|
||||
|
Reference in New Issue
Block a user