fail_bound_overflow.carbon 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/array/fail_bound_overflow.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/fail_bound_overflow.carbon
  10. // CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+4]]:14: error: array bound of 39999999999999999993 is too large [ArrayBoundTooLarge]
  11. // CHECK:STDERR: var a: [i32; 39999999999999999993];
  12. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  13. // CHECK:STDERR:
  14. var a: [i32; 39999999999999999993];
  15. // CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+6]]:9: error: cannot implicitly convert from `Core.IntLiteral` to `type` [ImplicitAsConversionFailure]
  16. // CHECK:STDERR: var b: [1; 39999999999999999993];
  17. // CHECK:STDERR: ^
  18. // CHECK:STDERR: fail_bound_overflow.carbon:[[@LINE+3]]:9: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
  19. // CHECK:STDERR: var b: [1; 39999999999999999993];
  20. // CHECK:STDERR: ^
  21. var b: [1; 39999999999999999993];
  22. // CHECK:STDOUT: --- fail_bound_overflow.carbon
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: constants {
  25. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  26. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  27. // CHECK:STDOUT: %int_39999999999999999993: Core.IntLiteral = int_value 39999999999999999993 [template]
  28. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  33. // CHECK:STDOUT: .Int = %import_ref.1
  34. // CHECK:STDOUT: .ImplicitAs = %import_ref.5
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/...
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: file {
  41. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  42. // CHECK:STDOUT: .Core = imports.%Core
  43. // CHECK:STDOUT: .a = %a
  44. // CHECK:STDOUT: .b = %b
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.import = import Core
  47. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  48. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  49. // CHECK:STDOUT: %int_39999999999999999993.loc15: Core.IntLiteral = int_value 39999999999999999993 [template = constants.%int_39999999999999999993]
  50. // CHECK:STDOUT: %array_type.loc15: type = array_type %int_39999999999999999993.loc15, %i32 [template = <error>]
  51. // CHECK:STDOUT: %a.var: ref <error> = var a
  52. // CHECK:STDOUT: %a: ref <error> = bind_name a, %a.var
  53. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  54. // CHECK:STDOUT: %int_39999999999999999993.loc23: Core.IntLiteral = int_value 39999999999999999993 [template = constants.%int_39999999999999999993]
  55. // CHECK:STDOUT: %.loc23: type = converted %int_1, <error> [template = <error>]
  56. // CHECK:STDOUT: %array_type.loc23: type = array_type %int_39999999999999999993.loc23, <error> [template = <error>]
  57. // CHECK:STDOUT: %b.var: ref <error> = var b
  58. // CHECK:STDOUT: %b: ref <error> = bind_name b, %b.var
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: