fail_generic.carbon 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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/var/no_prelude/fail_generic.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/no_prelude/fail_generic.carbon
  10. fn Main() {
  11. // CHECK:STDERR: fail_generic.carbon:[[@LINE+3]]:11: error: `var` declaration cannot declare a compile-time binding
  12. // CHECK:STDERR: var x:! () = ();
  13. // CHECK:STDERR: ^~
  14. var x:! () = ();
  15. }
  16. // CHECK:STDOUT: --- fail_generic.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  20. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  21. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  22. // CHECK:STDOUT: %x: %.1 = bind_symbolic_name x 0 [symbolic]
  23. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  28. // CHECK:STDOUT: .Main = %Main.decl
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: fn @Main() {
  34. // CHECK:STDOUT: !entry:
  35. // CHECK:STDOUT: %.loc15_12.1: %.1 = tuple_literal ()
  36. // CHECK:STDOUT: %.loc15_12.2: type = converted %.loc15_12.1, constants.%.1 [template = constants.%.1]
  37. // CHECK:STDOUT: %x.var: ref %.1 = var x
  38. // CHECK:STDOUT: %x: %.1 = bind_symbolic_name x 0, %x.var [symbolic = constants.%x]
  39. // CHECK:STDOUT: %.loc15_17.1: %.1 = tuple_literal ()
  40. // CHECK:STDOUT: %.loc15_17.2: init %.1 = tuple_init () to %x.var [template = constants.%tuple]
  41. // CHECK:STDOUT: %.loc15_18: init %.1 = converted %.loc15_17.1, %.loc15_17.2 [template = constants.%tuple]
  42. // CHECK:STDOUT: assign %x.var, %.loc15_18
  43. // CHECK:STDOUT: return
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: