fail_bound_overflow.carbon 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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+7]]: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+4]]:9: note: type `Core.IntLiteral` does not implement interface `Core.ImplicitAs(type)` [MissingImplInMemberAccessNote]
  19. // CHECK:STDERR: var b: [1; 39999999999999999993];
  20. // CHECK:STDERR: ^
  21. // CHECK:STDERR:
  22. var b: [1; 39999999999999999993];
  23. // CHECK:STDOUT: --- fail_bound_overflow.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  27. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  28. // CHECK:STDOUT: %int_39999999999999999993: Core.IntLiteral = int_value 39999999999999999993 [template]
  29. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  34. // CHECK:STDOUT: .Int = %Core.Int
  35. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  36. // CHECK:STDOUT: import Core//prelude
  37. // CHECK:STDOUT: import Core//prelude/...
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  43. // CHECK:STDOUT: .Core = imports.%Core
  44. // CHECK:STDOUT: .a = %a
  45. // CHECK:STDOUT: .b = %b
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %Core.import = import Core
  48. // CHECK:STDOUT: name_binding_decl {
  49. // CHECK:STDOUT: %a.patt: <error> = binding_pattern a
  50. // CHECK:STDOUT: %.loc15_1: <error> = var_pattern %a.patt
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %a.var: ref <error> = var a
  53. // CHECK:STDOUT: %.loc15_34: type = splice_block %array_type.loc15 [template = <error>] {
  54. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  55. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  56. // CHECK:STDOUT: %int_39999999999999999993.loc15: Core.IntLiteral = int_value 39999999999999999993 [template = constants.%int_39999999999999999993]
  57. // CHECK:STDOUT: %array_type.loc15: type = array_type %int_39999999999999999993.loc15, %i32 [template = <error>]
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: %a: <error> = bind_name a, <error>
  60. // CHECK:STDOUT: name_binding_decl {
  61. // CHECK:STDOUT: %b.patt: <error> = binding_pattern b
  62. // CHECK:STDOUT: %.loc24_1: <error> = var_pattern %b.patt
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: %b.var: ref <error> = var b
  65. // CHECK:STDOUT: %.loc24_32: type = splice_block %array_type.loc24 [template = <error>] {
  66. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1]
  67. // CHECK:STDOUT: %int_39999999999999999993.loc24: Core.IntLiteral = int_value 39999999999999999993 [template = constants.%int_39999999999999999993]
  68. // CHECK:STDOUT: %.loc24_9: type = converted %int_1, <error> [template = <error>]
  69. // CHECK:STDOUT: %array_type.loc24: type = array_type %int_39999999999999999993.loc24, <error> [template = <error>]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: %b: <error> = bind_name b, <error>
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: