@@ -251,32 +251,26 @@ main {
251251 val src="""
252252main {
253253 sub start() {
254- ubyte[10] array
255- array[-11] = 0
256- }
257- }"""
258- val errors = ErrorReporterForTests ()
259- compileText(VMTarget (), false, src, outputDir, writeAssembly = false, errors = errors) shouldBe null
260- errors.errors.size shouldBe 1
261- errors.errors[0 ] shouldContain " out of bounds"
262- }
254+ ubyte[] array = ['h', 'e', 'l', 'l', 'o', 0]
255+ str name = "hello"
263256
264- test("bounds checking on strings invalid cases") {
265- val src= """
266- main {
267- sub start() {
268- str name = "1234567890"
269- name[10 ] = 0
270- name[-1] = 0
271- name[-11] = 0
257+ name[-5] = 99 ; ok
258+ name[-6] = 99 ; out of bounds
259+ cx16.r1L = name[-5] ; ok
260+ cx16.r1L = name[-6] ; out of bounds
261+ array[-6] = 99 ; ok
262+ array[-7 ] = 99 ; out of bounds
263+ cx16.r1L = array[-6] ; ok
264+ cx16.r1L = array[-7] ; out of bounds
272265 }
273266}"""
274267 val errors = ErrorReporterForTests ()
275268 compileText(VMTarget (), false, src, outputDir, writeAssembly = false, errors = errors) shouldBe null
276- errors.errors.size shouldBe 3
277- errors.errors[0 ] shouldContain " out of bounds"
278- errors.errors[1 ] shouldContain " out of bounds"
279- errors.errors[2 ] shouldContain " out of bounds"
269+ errors.errors.size shouldBe 4
270+ errors.errors[0 ] shouldContain " :8:9: index out of bounds"
271+ errors.errors[1 ] shouldContain " :10:20: index out of bounds"
272+ errors.errors[2 ] shouldContain " :12:9: index out of bounds"
273+ errors.errors[3 ] shouldContain " :14:20: index out of bounds"
280274 }
281275
282276 test("array and string initializer with multiplication") {
0 commit comments