Restructure __intrinsic_print to be a keyword-like Print (#1407)

This commit is contained in:
Jon Ross-Perkins
2022-07-18 13:58:08 -04:00
committed by GitHub
parent 4296e1e780
commit 084bc6ebc1
12 changed files with 93 additions and 20 deletions
+3 -3
View File
@@ -39,8 +39,8 @@ fn Main() -> i32 {
var d: GenericClassAlias(i32) = c;
var e: ClassSpecializationAlias = c;
PrintInt("b.n: {0}", b.n);
PrintInt("d.Get(0): {0}", d.Get(0));
PrintInt("e.Get(1): {0}", e.Get(1));
Print("b.n: {0}", b.n);
Print("d.Get(0): {0}", d.Get(0));
Print("e.Get(1): {0}", e.Get(1));
return 0;
}
+4 -4
View File
@@ -21,9 +21,9 @@ alias BA = {.b: i32, .a: i32};
fn Main() -> i32 {
var ab: AB = {.b = 1, .a = 2};
var ba: BA = ab;
PrintInt("ab.a: {0}", ab.a);
PrintInt("ab.b: {0}", ab.b);
PrintInt("ba.a: {0}", ba.a);
PrintInt("ba.b: {0}", ba.b);
Print("ab.a: {0}", ab.a);
Print("ab.b: {0}", ab.b);
Print("ba.a: {0}", ba.a);
Print("ba.b: {0}", ba.b);
return 0;
}
+3 -3
View File
@@ -10,11 +10,11 @@
//
// NOAUTOUPDATE
// CHECK: ********** source program **********
// CHECK: fn Print (format_str: String) {
// CHECK: interface ImplicitAs {
// CHECK: ********** type checking **********
// CHECK: checking tuple pattern (format_str: String)
// CHECK: ** declaring interface ImplicitAs
// CHECK: ********** type checking complete **********
// CHECK: fn Print (format_str: String) {
// CHECK: interface ImplicitAs {
// CHECK: ********** starting execution **********
// CHECK: ********** initializing globals **********
// CHECK: ********** calling main function **********
+17
View File
@@ -0,0 +1,17 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{not} %{explorer} %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: %{explorer} %s
package ExplorerTest api;
fn Main() -> i32 {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/print/fail_no_args.carbon:[[@LINE+1]]: __intrinsic_print takes 1 or 2 arguments, received 0
Print();
return 0;
}
+19
View File
@@ -0,0 +1,19 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{not} %{explorer} %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: %{explorer} %s
package ExplorerTest api;
fn Main() -> i32 {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/print/fail_not_str.carbon:[[@LINE+3]]: type error in __intrinsic_print argument 0
// CHECK: expected: String
// CHECK: actual: {.x: i32}
Print({.x = 1});
return 0;
}
+17
View File
@@ -0,0 +1,17 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{not} %{explorer} %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: %{explorer} %s
package ExplorerTest api;
fn Main() -> i32 {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/print/fail_too_many_args.carbon:[[@LINE+1]]: __intrinsic_print takes 1 or 2 arguments, received 5
Print("too", "many", "args", "to", "print");
return 0;
}
+19
View File
@@ -0,0 +1,19 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// RUN: %{not} %{explorer} %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
// RUN: %{not} %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
// RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
// AUTOUPDATE: %{explorer} %s
package ExplorerTest api;
fn Main() -> i32 {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/print/fail_type.carbon:[[@LINE+3]]: type error in __intrinsic_print argument 1
// CHECK: expected: i32
// CHECK: actual: {.x: i32}
Print("{0}", {.x = 1});
return 0;
}
@@ -13,6 +13,6 @@
package ExplorerTest api;
fn Main() -> i32 {
PrintInt("Printing {0}", 1);
Print("Printing {0}", 1);
return 0;
}