string_repeat_overflow.gravity 338 B

123456789101112
  1. #unittest {
  2. name: "String repeat overflow protection.";
  3. error: RUNTIME;
  4. };
  5. func main() {
  6. // A long string repeated many times should trigger overflow protection
  7. // even if each individual value is under the max limit
  8. var s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  9. // 26 * 200000000 > UINT32_MAX, should error
  10. return s.repeat(200000000);
  11. }