From e26bc323434195d008bd35de6068f42a0ac08104 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 3 Aug 2022 20:55:34 -0400 Subject: [PATCH] Change remaining uses of `Bool` to `bool`, following #750. (#1901) The most significant change here is that explorer now uses the chosen spelling rather than the old `Bool` spelling. Also update a few documentation examples and some skeletal design docs to use the chosen spelling. --- common/fuzzing/proto_to_carbon.cpp | 2 +- docs/design/classes.md | 6 ++-- docs/design/generics/goals.md | 2 +- docs/design/generics/overview.md | 12 ++++---- docs/design/generics/terminology.md | 2 +- docs/design/name_lookup.md | 10 +++---- docs/design/primitive_types.md | 30 +++++++++++-------- docs/project/principles/error_handling.md | 2 +- docs/project/principles/library_apis_only.md | 2 +- explorer/ast/expression.cpp | 2 +- explorer/data/prelude.carbon | 8 ++--- explorer/interpreter/interpreter.cpp | 4 +-- explorer/interpreter/value.cpp | 2 +- explorer/syntax/lexer.lpp | 2 +- .../not_compare_precedence.carbon | 2 +- .../comparison/custom_equality.carbon | 2 +- .../comparison/fail_empty_struct.carbon | 2 +- .../auto_return/fail_direct_recurse.carbon | 2 +- .../fail_argument_deduction.carbon | 4 +-- .../generic_class/fail_point_equal.carbon | 4 +-- .../testdata/generic_function/apply.carbon | 2 +- .../fail_type_deduction_mismatch.carbon | 2 +- .../fail_init_type_mismatch.carbon | 2 +- .../testdata/if_else/convert_condition.carbon | 4 +-- .../if_expression/convert_condition.carbon | 4 +-- .../if_expression/if_then_else.carbon | 2 +- .../impl/fail_ambiguous_impl_generic.carbon | 4 +-- .../impl/fail_param_interface_in_impl.carbon | 2 +- .../operators/shortcircuit_and.carbon | 4 +-- .../shortcircuit_and_no_shortcircuit.carbon | 4 +-- .../testdata/operators/shortcircuit_or.carbon | 4 +-- .../shortcircuit_or_no_shortcircuit.carbon | 4 +-- explorer/testdata/random/random.carbon | 2 +- .../fail_returned_var_type_mismatch.carbon | 4 +-- explorer/testdata/struct/equality.carbon | 2 +- .../testdata/struct/equality_false.carbon | 2 +- .../testdata/struct/fail_equality_type.carbon | 2 +- .../testdata/while/convert_condition.carbon | 4 +-- third_party/examples/re2/re2.carbon | 2 +- 39 files changed, 81 insertions(+), 77 deletions(-) diff --git a/common/fuzzing/proto_to_carbon.cpp b/common/fuzzing/proto_to_carbon.cpp index 6f9caf64a77a..8185c62d09f5 100644 --- a/common/fuzzing/proto_to_carbon.cpp +++ b/common/fuzzing/proto_to_carbon.cpp @@ -321,7 +321,7 @@ static auto ExpressionToCarbon(const Fuzzing::Expression& expression, } case Fuzzing::Expression::kBoolTypeLiteral: - out << "Bool"; + out << "bool"; break; case Fuzzing::Expression::kBoolLiteral: { diff --git a/docs/design/classes.md b/docs/design/classes.md index c28429fc801b..5c66afb20308 100644 --- a/docs/design/classes.md +++ b/docs/design/classes.md @@ -1755,8 +1755,8 @@ declaration with all of the optional parameters in an option struct: ``` fn SortIntVector( v: Vector(i32)*, - options: {.stable: Bool = false, - .descending: Bool = false} = {}) { + options: {.stable: bool = false, + .descending: bool = false} = {}) { // Code using `options.stable` and `options.descending`. } @@ -1780,7 +1780,7 @@ We might instead support destructuring struct patterns with defaults: ``` fn SortIntVector( v: Vector(i32)*, - {stable: Bool = false, descending: Bool = false}) { + {stable: bool = false, descending: bool = false}) { // Code using `stable` and `descending`. } ``` diff --git a/docs/design/generics/goals.md b/docs/design/generics/goals.md index e28eb05cc29f..b69ae78d2fe0 100644 --- a/docs/design/generics/goals.md +++ b/docs/design/generics/goals.md @@ -381,7 +381,7 @@ There are a few obstacles to supporting dynamic dispatch efficiently, which may limit the extent it is used automatically by implementations. For example, the following features would benefit substantially from guaranteed monomorphization: -- Field packing in class layout. For example, packing a `Bool` into the lower +- Field packing in class layout. For example, packing a `bool` into the lower bits of a pointer, or packing bit-fields with generic widths. - Allocating local variables in stack storage. Without monomorphization, we would need to perform dynamic memory allocation -- whether on the stack or diff --git a/docs/design/generics/overview.md b/docs/design/generics/overview.md index 449a6155b344..7f24b985840a 100644 --- a/docs/design/generics/overview.md +++ b/docs/design/generics/overview.md @@ -159,7 +159,7 @@ Example: ``` interface Comparable { // `Less` is an associated method. - fn Less[me: Self](rhs: Self) -> Bool; + fn Less[me: Self](rhs: Self) -> bool; } ``` @@ -218,7 +218,7 @@ class Song { // the library defining `Song` or `Comparable`. external impl Song as Comparable { // Could use either `Self` or `Song` here. - fn Less[me: Self](rhs: Self) -> Bool { ... } + fn Less[me: Self](rhs: Self) -> bool { ... } } ``` @@ -350,7 +350,7 @@ Interfaces can require other interfaces be implemented: ``` interface Equatable { - fn IsEqual[me: Self](rhs: Self) -> Bool; + fn IsEqual[me: Self](rhs: Self) -> bool; } // `Iterable` requires that `Equatable` is implemented. @@ -386,7 +386,7 @@ methods in the implementation of the derived interface. class Key { // ... impl as Hashable { - fn IsEqual[me: Key](rhs: Key) -> Bool { ... } + fn IsEqual[me: Key](rhs: Key) -> bool { ... } fn Hash[me: Key]() -> u64 { ... } } // No need to separately implement `Equatable`. @@ -535,7 +535,7 @@ interface Stack { let ElementType:! Movable; fn Push[addr me: Self*](value: ElementType); fn Pop[addr me: Self*]() -> ElementType; - fn IsEmpty[addr me: Self*]() -> Bool; + fn IsEmpty[addr me: Self*]() -> bool; } ``` @@ -561,7 +561,7 @@ those types to be different. An element in a hash map might have type ``` interface Equatable(T:! Type) { - fn IsEqual[me: Self](compare_to: T) -> Bool; + fn IsEqual[me: Self](compare_to: T) -> bool; } ``` diff --git a/docs/design/generics/terminology.md b/docs/design/generics/terminology.md index 33d9ad7a41c9..17c9cb5800ca 100644 --- a/docs/design/generics/terminology.md +++ b/docs/design/generics/terminology.md @@ -192,7 +192,7 @@ overloads: ``` fn F[template T:! Type](x: T*) -> T; -fn F(x: Int) -> Bool; +fn F(x: Int) -> bool; ``` A generic function `G` can call `F` with a type like `T*` that can not possibly diff --git a/docs/design/name_lookup.md b/docs/design/name_lookup.md index e82d2323ace8..1b392f5c96b4 100644 --- a/docs/design/name_lookup.md +++ b/docs/design/name_lookup.md @@ -76,12 +76,12 @@ the package scope for unqualified name lookup. The Carbon standard library is in the `Carbon` package. A very small subset of this standard library is provided implicitly in every file's scope. This is -called the "prelude" package. +called the "prelude". -Names in the prelude package will be available without scoping names. For -example, `Bool` will be the commonly used name in code, even though the -underlying type may be `Carbon::Bool`. Also, no `import` will be necessary to -use `Bool`. +Names in the prelude will be available without a package qualifier. For example, +the name `Type` can be directly used in code without a `Carbon.` qualifier, even +though it belongs to the `Carbon` package, and no import is necessary to use the +name `Type`. ## Open questions diff --git a/docs/design/primitive_types.md b/docs/design/primitive_types.md index b503271c2a4b..1307f817fd12 100644 --- a/docs/design/primitive_types.md +++ b/docs/design/primitive_types.md @@ -37,33 +37,37 @@ modifying other types. They also have semantics that are defined from first principles rather than in terms of other operations. These will be made available through the [prelude package](README.md#name-lookup-for-common-types). -- `Bool` - a boolean type with two possible values: `True` and `False`. -- `Int` and `UInt` - signed and unsigned 64-bit integer types. +- `bool` - a boolean type with two possible values: `true` and `false`. +- Signed and unsigned 64-bit integer types: - Standard sizes are available, both signed and unsigned, including `i8`, - `i16`, `i32`, `i64`, `i128`, and `i256`. - - Overflow in either direction is an error. -- `Float64` - a floating point type with semantics based on IEEE-754. - - Standard sizes are available, including `f16`, `f32`, and `f128`. + `i16`, `i32`, `i64`, and `i128`, and `u8`, `u16`, `u32`, `u64`, and + `u128`. + - Signed overflow in either direction is an error. +- Floating points type with semantics based on IEEE-754. + - Standard sizes are available, including `f16`, `f32`, and `f64`. - [`BFloat16`](primitive_types.md#bfloat16) is also provided. - `String` - a byte sequence treated as containing UTF-8 encoded text. - `StringView` - a read-only reference to a byte sequence treated as containing UTF-8 encoded text. +The names `bool`, `true`, and `false` are keywords, and identifiers of the form +`i[0-9]*`, `u[0-9]*`, and `f[0-9*]` are _type literals_, resulting in the +corresponding type. + ### Integers Integer types can be either signed or unsigned, much like in C++. Signed integers are represented using 2's complement and notionally modeled as -unbounded natural numbers. Overflow in either direction is an error. That -includes unsigned integers, differing from C++. The default size for both is -64-bits: `Int` and `UInt`. Specific sizes are also available, for example: -`Int8`, `Int16`, `Int32`, `Int128`, `UInt256`. Arbitrary powers of two above `8` -are supported for both (although perhaps we'll want to avoid _huge_ values for -implementation simplicity). +unbounded natural numbers. Signed overflow in either direction is an error. +Specific sizes are available, for example: `i8`, `u16`, `i32`, and `u128`. + +There is an upper bound on the size of an integer, most likely initially set to +128 bits due to LLVM limitations. ### Floats Floating point types are based on the binary floating point formats provided by -IEEE-754. `Float16`, `Float32`, `Float64` and `Float128` correspond exactly to +IEEE-754. `f16`, `f32`, `f64` and, if available, `f128` correspond exactly to those sized IEEE-754 formats, and have the semantics defined by IEEE-754. ### BFloat16 diff --git a/docs/project/principles/error_handling.md b/docs/project/principles/error_handling.md index 01b38da83c33..8df946f23098 100644 --- a/docs/project/principles/error_handling.md +++ b/docs/project/principles/error_handling.md @@ -32,7 +32,7 @@ way that enables the program to continue running. A Carbon function that needs to report recoverable failures should return a sum type whose alternatives represent the success case and failure cases, such as -`Optional(T)`, `Result(T, Error)`, or `Bool`. The function's successful return +`Optional(T)`, `Result(T, Error)`, or `bool`. The function's successful return value, and any metadata about the failure, should be embedded in the alternatives of the sum type, rather than reported by way of output parameters or other side channels. Carbon's design will prioritize making this form of diff --git a/docs/project/principles/library_apis_only.md b/docs/project/principles/library_apis_only.md index 7029b4a49e68..a32b9b95e13d 100644 --- a/docs/project/principles/library_apis_only.md +++ b/docs/project/principles/library_apis_only.md @@ -61,7 +61,7 @@ lookup as well. According to the resolutions of [#543](https://github.com/carbon-language/carbon-lang/issues/543) and -[#750](https://github.com/carbon-language/carbon-lang/issues/543), Carbon will +[#750](https://github.com/carbon-language/carbon-lang/issues/750), Carbon will have a substantial number of type keywords, such as `i32`, `f64`, and `bool`. However, these keywords will all be aliases for ordinary type names, such as `Carbon.Int(32)`, `Carbon.Float(64)`, and `Carbon.Bool`. Furthermore, all diff --git a/explorer/ast/expression.cpp b/explorer/ast/expression.cpp index 0a1cbcc640f1..7a7bf933abcd 100644 --- a/explorer/ast/expression.cpp +++ b/explorer/ast/expression.cpp @@ -288,7 +288,7 @@ void Expression::PrintID(llvm::raw_ostream& out) const { out << (cast(*this).value() ? "true" : "false"); break; case ExpressionKind::BoolTypeLiteral: - out << "Bool"; + out << "bool"; break; case ExpressionKind::IntTypeLiteral: out << "i32"; diff --git a/explorer/data/prelude.carbon b/explorer/data/prelude.carbon index 59cfe6a26fcd..542244259862 100644 --- a/explorer/data/prelude.carbon +++ b/explorer/data/prelude.carbon @@ -58,7 +58,7 @@ impl forall [U1:! Type, U2:! Type, U3:! Type, // ---------------------- interface EqWith(U:! Type) { - fn Equal[me: Self](other: U) -> Bool; + fn Equal[me: Self](other: U) -> bool; // TODO: NotEqual with default impl } // TODO: constraint Eq { ... } @@ -67,7 +67,7 @@ interface EqWith(U:! Type) { // TODO: Simplify this once we have variadics impl forall [T2:! Type, U2:! Type, T1:! EqWith(T2), U1:! EqWith(U2)] (T1, U1) as EqWith((T2, U2)) { - fn Equal[me: Self](other: (T2, U2)) -> Bool { + fn Equal[me: Self](other: (T2, U2)) -> bool { let (l1: T1, l2: U1) = me; let (r1: T2, r2: U2) = other; return l1 == r1 and l2 == r2; @@ -75,13 +75,13 @@ impl forall [T2:! Type, U2:! Type, T1:! EqWith(T2), U1:! EqWith(U2)] } impl i32 as EqWith(Self) { - fn Equal[me: Self](other: Self) -> Bool { + fn Equal[me: Self](other: Self) -> bool { return __intrinsic_int_eq(me, other); } } impl String as EqWith(Self) { - fn Equal[me: Self](other: Self) -> Bool { + fn Equal[me: Self](other: Self) -> bool { return __intrinsic_str_eq(me, other); } } diff --git a/explorer/interpreter/interpreter.cpp b/explorer/interpreter/interpreter.cpp index 494267ea3be5..f0130719fe4d 100644 --- a/explorer/interpreter/interpreter.cpp +++ b/explorer/interpreter/interpreter.cpp @@ -123,10 +123,10 @@ class Interpreter { // Instantiate a type by replacing all type variables that occur inside the // type by the current values of those variables. // - // For example, suppose T=i32 and U=Bool. Then + // For example, suppose T=i32 and U=bool. Then // __Fn (Point(T)) -> Point(U) // becomes - // __Fn (Point(i32)) -> Point(Bool) + // __Fn (Point(i32)) -> Point(bool) auto InstantiateType(Nonnull type, SourceLocation source_loc) -> ErrorOr>; diff --git a/explorer/interpreter/value.cpp b/explorer/interpreter/value.cpp index d921fa361cdb..bafa78ad06df 100644 --- a/explorer/interpreter/value.cpp +++ b/explorer/interpreter/value.cpp @@ -340,7 +340,7 @@ void Value::Print(llvm::raw_ostream& out) const { out << "lval<" << cast(*this).address() << ">"; break; case Value::Kind::BoolType: - out << "Bool"; + out << "bool"; break; case Value::Kind::IntType: out << "i32"; diff --git a/explorer/syntax/lexer.lpp b/explorer/syntax/lexer.lpp index 1fa891e19f9c..6c1ee2b204a3 100644 --- a/explorer/syntax/lexer.lpp +++ b/explorer/syntax/lexer.lpp @@ -42,7 +42,7 @@ AS "as" AUTO "auto" AWAIT "__await" BASE "base" -BOOL "Bool" +BOOL "bool" BREAK "break" CARET "^" CASE "case" diff --git a/explorer/testdata/basic_syntax/not_compare_precedence.carbon b/explorer/testdata/basic_syntax/not_compare_precedence.carbon index 3639bb5be7c9..6c5ca091a5ef 100644 --- a/explorer/testdata/basic_syntax/not_compare_precedence.carbon +++ b/explorer/testdata/basic_syntax/not_compare_precedence.carbon @@ -10,7 +10,7 @@ package ExplorerTest api; -fn CompareBools(a: Bool, b: Bool) -> Bool { +fn CompareBools(a: bool, b: bool) -> bool { // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/basic_syntax/not_compare_precedence.carbon:[[@LINE+1]]: syntax error, unexpected EQUAL_EQUAL, expecting SEMICOLON return not a == b; } diff --git a/explorer/testdata/comparison/custom_equality.carbon b/explorer/testdata/comparison/custom_equality.carbon index 90ed478ba092..0cf3e8909480 100644 --- a/explorer/testdata/comparison/custom_equality.carbon +++ b/explorer/testdata/comparison/custom_equality.carbon @@ -16,7 +16,7 @@ class MyType { var value: i32; impl as EqWith(Self) { - fn Equal[me: Self](other: Self) -> Bool { + fn Equal[me: Self](other: Self) -> bool { return me.value == other.value; } } diff --git a/explorer/testdata/comparison/fail_empty_struct.carbon b/explorer/testdata/comparison/fail_empty_struct.carbon index c3620e6be145..5e701cca79e3 100644 --- a/explorer/testdata/comparison/fail_empty_struct.carbon +++ b/explorer/testdata/comparison/fail_empty_struct.carbon @@ -10,7 +10,7 @@ package ExplorerTest api; // TODO: This should work // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/comparison/fail_empty_struct.carbon:[[@LINE+1]]: type error in call: '{}' is not implicitly convertible to 'Type' external impl {} as EqWith({}) { - fn Equal[me: Self](other: Self) -> Bool { + fn Equal[me: Self](other: Self) -> bool { return true; } } diff --git a/explorer/testdata/function/auto_return/fail_direct_recurse.carbon b/explorer/testdata/function/auto_return/fail_direct_recurse.carbon index 92fefab0dcc5..f2805ed32460 100644 --- a/explorer/testdata/function/auto_return/fail_direct_recurse.carbon +++ b/explorer/testdata/function/auto_return/fail_direct_recurse.carbon @@ -12,7 +12,7 @@ package ExplorerTest api; // This is required to fail even though the Recurse() call's return value isn't // used. -fn Recurse(x: i32, do_recurse: Bool) -> auto { +fn Recurse(x: i32, do_recurse: bool) -> auto { if (do_recurse) { // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/function/auto_return/fail_direct_recurse.carbon:[[@LINE+1]]: Function calls itself, but has a deduced return type Recurse(x, false); diff --git a/explorer/testdata/generic_class/fail_argument_deduction.carbon b/explorer/testdata/generic_class/fail_argument_deduction.carbon index 4157657ef361..5ad7276d4b52 100644 --- a/explorer/testdata/generic_class/fail_argument_deduction.carbon +++ b/explorer/testdata/generic_class/fail_argument_deduction.carbon @@ -21,9 +21,9 @@ fn FirstOfTwoPoints[T:! Type](a: Point(T), b: Point(T)) -> Point(T) { fn Main() -> i32 { var p: Point(i32) = {.x = 0, .y = 1}; - var q: Point(Bool) = {.x = true, .y = false}; + var q: Point(bool) = {.x = true, .y = false}; // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_argument_deduction.carbon:[[@LINE+3]]: deduced multiple different values for T:! Type: // CHECK: i32 - // CHECK: Bool + // CHECK: bool return FirstOfTwoPoints(p, q).x; } diff --git a/explorer/testdata/generic_class/fail_point_equal.carbon b/explorer/testdata/generic_class/fail_point_equal.carbon index c165f62ab96d..442704d45813 100644 --- a/explorer/testdata/generic_class/fail_point_equal.carbon +++ b/explorer/testdata/generic_class/fail_point_equal.carbon @@ -17,7 +17,7 @@ class Point(T:! Type) { fn Main() -> i32 { var p: Point(i32) = {.x = 0, .y = 0}; - // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_point_equal.carbon:[[@LINE+1]]: type error in name binding: 'class Point(T = i32)' is not implicitly convertible to 'class Point(T = Bool)' - var q: Point(Bool) = p; + // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_point_equal.carbon:[[@LINE+1]]: type error in name binding: 'class Point(T = i32)' is not implicitly convertible to 'class Point(T = bool)' + var q: Point(bool) = p; return 0; } diff --git a/explorer/testdata/generic_function/apply.carbon b/explorer/testdata/generic_function/apply.carbon index 1800ecc5dab0..23adb60b3c55 100644 --- a/explorer/testdata/generic_function/apply.carbon +++ b/explorer/testdata/generic_function/apply.carbon @@ -15,7 +15,7 @@ fn apply[T:! Type, U:! Type](f: __Fn (T) -> U, x: T) -> U { return f(x); } -fn positive(x: Bool) -> i32 { +fn positive(x: bool) -> i32 { if (x) { return 2; } else { diff --git a/explorer/testdata/generic_function/fail_type_deduction_mismatch.carbon b/explorer/testdata/generic_function/fail_type_deduction_mismatch.carbon index 88204d995359..95908dc0016c 100644 --- a/explorer/testdata/generic_function/fail_type_deduction_mismatch.carbon +++ b/explorer/testdata/generic_function/fail_type_deduction_mismatch.carbon @@ -17,6 +17,6 @@ fn fst[T:! Type](x: T, y: T) -> T { fn Main() -> i32 { // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_function/fail_type_deduction_mismatch.carbon:[[@LINE+3]]: deduced multiple different values for T:! Type: // CHECK: i32 - // CHECK: Bool + // CHECK: bool return fst(0, true); } diff --git a/explorer/testdata/global_variable/fail_init_type_mismatch.carbon b/explorer/testdata/global_variable/fail_init_type_mismatch.carbon index 559c51983b6c..0f941d8a5c5b 100644 --- a/explorer/testdata/global_variable/fail_init_type_mismatch.carbon +++ b/explorer/testdata/global_variable/fail_init_type_mismatch.carbon @@ -12,7 +12,7 @@ package ExplorerTest api; // Test type checking of global variable. Error expected. -// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/global_variable/fail_init_type_mismatch.carbon:[[@LINE+1]]: type error in initializer of variable: 'Bool' is not implicitly convertible to 'i32' +// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/global_variable/fail_init_type_mismatch.carbon:[[@LINE+1]]: type error in initializer of variable: 'bool' is not implicitly convertible to 'i32' var flag: i32 = true; fn Main() -> i32 { diff --git a/explorer/testdata/if_else/convert_condition.carbon b/explorer/testdata/if_else/convert_condition.carbon index 44c8d7e160e8..63e34fa09f0f 100644 --- a/explorer/testdata/if_else/convert_condition.carbon +++ b/explorer/testdata/if_else/convert_condition.carbon @@ -14,8 +14,8 @@ package ExplorerTest api; class LazyEq { var v1: i32; var v2: i32; - impl as ImplicitAs(Bool) { - fn Convert[me: Self]() -> Bool { + impl as ImplicitAs(bool) { + fn Convert[me: Self]() -> bool { return me.v1 == me.v2; } } diff --git a/explorer/testdata/if_expression/convert_condition.carbon b/explorer/testdata/if_expression/convert_condition.carbon index 34c0337747bc..3bc3fa124eaf 100644 --- a/explorer/testdata/if_expression/convert_condition.carbon +++ b/explorer/testdata/if_expression/convert_condition.carbon @@ -14,8 +14,8 @@ package ExplorerTest api; class LazyEq { var v1: i32; var v2: i32; - impl as ImplicitAs(Bool) { - fn Convert[me: Self]() -> Bool { + impl as ImplicitAs(bool) { + fn Convert[me: Self]() -> bool { return me.v1 == me.v2; } } diff --git a/explorer/testdata/if_expression/if_then_else.carbon b/explorer/testdata/if_expression/if_then_else.carbon index a95f0fabee2d..aa32a1aed16f 100644 --- a/explorer/testdata/if_expression/if_then_else.carbon +++ b/explorer/testdata/if_expression/if_then_else.carbon @@ -12,7 +12,7 @@ package ExplorerTest api; fn Main() -> i32 { - var cond: if true then Bool else i32 = true; + var cond: if true then bool else i32 = true; if (if cond then true else false) {} while (if cond then false else true) {} return if if cond then true or false else false and true diff --git a/explorer/testdata/impl/fail_ambiguous_impl_generic.carbon b/explorer/testdata/impl/fail_ambiguous_impl_generic.carbon index f24ed3c64a2a..0854a76a6d03 100644 --- a/explorer/testdata/impl/fail_ambiguous_impl_generic.carbon +++ b/explorer/testdata/impl/fail_ambiguous_impl_generic.carbon @@ -17,10 +17,10 @@ external impl forall [T:! Type] A(T) as B(i32) {} external impl forall [T:! Type] A(i32) as B(T) {} fn F[T:! B(i32)](x: T) {} -fn G[T:! B(Bool)](x: T) {} +fn G[T:! B(bool)](x: T) {} fn Main() -> i32 { - let a: A(Bool) = {}; + let a: A(bool) = {}; let b: A(i32) = {}; F(a); G(b); diff --git a/explorer/testdata/impl/fail_param_interface_in_impl.carbon b/explorer/testdata/impl/fail_param_interface_in_impl.carbon index 01e77cec361b..1baa85dbb07d 100644 --- a/explorer/testdata/impl/fail_param_interface_in_impl.carbon +++ b/explorer/testdata/impl/fail_param_interface_in_impl.carbon @@ -21,7 +21,7 @@ fn Main() -> i32 { let n: i32 = 0; CheckSimilar(true, false); CheckSimilar(true, n); - // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/impl/fail_param_interface_in_impl.carbon:[[@LINE+1]]: could not find implementation of interface Similar(T = i32) for Bool + // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/impl/fail_param_interface_in_impl.carbon:[[@LINE+1]]: could not find implementation of interface Similar(T = i32) for bool CheckSimilar(n, false); return 0; } diff --git a/explorer/testdata/operators/shortcircuit_and.carbon b/explorer/testdata/operators/shortcircuit_and.carbon index 2773859a9021..0f789bbdc719 100644 --- a/explorer/testdata/operators/shortcircuit_and.carbon +++ b/explorer/testdata/operators/shortcircuit_and.carbon @@ -12,12 +12,12 @@ package ExplorerTest api; var call_count: i32 = 0; -fn ReturnFalse() -> Bool { +fn ReturnFalse() -> bool { call_count = call_count + 1; return false; } fn Main() -> i32 { - var result: Bool = ReturnFalse() and ReturnFalse(); + var result: bool = ReturnFalse() and ReturnFalse(); return if not result then call_count else -1; } diff --git a/explorer/testdata/operators/shortcircuit_and_no_shortcircuit.carbon b/explorer/testdata/operators/shortcircuit_and_no_shortcircuit.carbon index f29fc7217713..2d97faa60db9 100644 --- a/explorer/testdata/operators/shortcircuit_and_no_shortcircuit.carbon +++ b/explorer/testdata/operators/shortcircuit_and_no_shortcircuit.carbon @@ -12,12 +12,12 @@ package ExplorerTest api; var call_count: i32 = 0; -fn ReturnTrue() -> Bool { +fn ReturnTrue() -> bool { call_count = call_count + 1; return true; } fn Main() -> i32 { - var result: Bool = ReturnTrue() and ReturnTrue(); + var result: bool = ReturnTrue() and ReturnTrue(); return if result then call_count else -1; } diff --git a/explorer/testdata/operators/shortcircuit_or.carbon b/explorer/testdata/operators/shortcircuit_or.carbon index 8ee8c4004d23..1f1e4427e4a2 100644 --- a/explorer/testdata/operators/shortcircuit_or.carbon +++ b/explorer/testdata/operators/shortcircuit_or.carbon @@ -12,12 +12,12 @@ package ExplorerTest api; var call_count: i32 = 0; -fn ReturnTrue() -> Bool { +fn ReturnTrue() -> bool { call_count = call_count + 1; return true; } fn Main() -> i32 { - var result: Bool = ReturnTrue() or ReturnTrue(); + var result: bool = ReturnTrue() or ReturnTrue(); return if result then call_count else -1; } diff --git a/explorer/testdata/operators/shortcircuit_or_no_shortcircuit.carbon b/explorer/testdata/operators/shortcircuit_or_no_shortcircuit.carbon index 374878926ce6..d9de7b61770a 100644 --- a/explorer/testdata/operators/shortcircuit_or_no_shortcircuit.carbon +++ b/explorer/testdata/operators/shortcircuit_or_no_shortcircuit.carbon @@ -12,12 +12,12 @@ package ExplorerTest api; var call_count: i32 = 0; -fn ReturnFalse() -> Bool { +fn ReturnFalse() -> bool { call_count = call_count + 1; return false; } fn Main() -> i32 { - var result: Bool = ReturnFalse() or ReturnFalse(); + var result: bool = ReturnFalse() or ReturnFalse(); return if not result then call_count else -1; } diff --git a/explorer/testdata/random/random.carbon b/explorer/testdata/random/random.carbon index 3fd0d095ad6b..6080b1c90718 100644 --- a/explorer/testdata/random/random.carbon +++ b/explorer/testdata/random/random.carbon @@ -10,7 +10,7 @@ // CHECK: result: 0 package ExplorerTest api; -fn test(para: i32)->Bool{ +fn test(para: i32)->bool{ return true; } fn Main() -> i32 { diff --git a/explorer/testdata/returned_var/fail_returned_var_type_mismatch.carbon b/explorer/testdata/returned_var/fail_returned_var_type_mismatch.carbon index 9020f65815fb..8c95bd40d330 100644 --- a/explorer/testdata/returned_var/fail_returned_var_type_mismatch.carbon +++ b/explorer/testdata/returned_var/fail_returned_var_type_mismatch.carbon @@ -11,8 +11,8 @@ package ExplorerTest api; fn AddInt(a: i32, b: i32) -> i32 { - // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/returned_var/fail_returned_var_type_mismatch.carbon:[[@LINE+1]]: type of returned var `Bool` does not match return type `i32` - returned var ret: Bool = true; + // CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/returned_var/fail_returned_var_type_mismatch.carbon:[[@LINE+1]]: type of returned var `bool` does not match return type `i32` + returned var ret: bool = true; return var; } diff --git a/explorer/testdata/struct/equality.carbon b/explorer/testdata/struct/equality.carbon index 073cd4eabdac..af3fe3172754 100644 --- a/explorer/testdata/struct/equality.carbon +++ b/explorer/testdata/struct/equality.carbon @@ -13,7 +13,7 @@ package ExplorerTest api; // TODO: Implement this with some kind of reflection? external impl {.x: i32, .y: i32} as EqWith(Self) { - fn Equal[me: Self](other: Self) -> Bool { + fn Equal[me: Self](other: Self) -> bool { return me.x == other.x and me.y == other.y; } } diff --git a/explorer/testdata/struct/equality_false.carbon b/explorer/testdata/struct/equality_false.carbon index bf354b571708..6d0e769dd9c9 100644 --- a/explorer/testdata/struct/equality_false.carbon +++ b/explorer/testdata/struct/equality_false.carbon @@ -13,7 +13,7 @@ package ExplorerTest api; // TODO: Implement this with some kind of reflection? external impl {.x: i32, .y: i32} as EqWith(Self) { - fn Equal[me: Self](other: Self) -> Bool { + fn Equal[me: Self](other: Self) -> bool { return me.x == other.x and me.y == other.y; } } diff --git a/explorer/testdata/struct/fail_equality_type.carbon b/explorer/testdata/struct/fail_equality_type.carbon index 1b90a0e46730..6807318fdcc0 100644 --- a/explorer/testdata/struct/fail_equality_type.carbon +++ b/explorer/testdata/struct/fail_equality_type.carbon @@ -9,7 +9,7 @@ package ExplorerTest api; // TODO: Implement this with some kind of reflection? external impl {.x: i32, .y: i32} as EqWith(Self) { - fn Equal[me: Self](other: Self) -> Bool { + fn Equal[me: Self](other: Self) -> bool { return me.x == other.x and me.y == other.y; } } diff --git a/explorer/testdata/while/convert_condition.carbon b/explorer/testdata/while/convert_condition.carbon index bf3b3a07bab4..30218d99dbc9 100644 --- a/explorer/testdata/while/convert_condition.carbon +++ b/explorer/testdata/while/convert_condition.carbon @@ -14,8 +14,8 @@ package ExplorerTest api; class LazyNe { var v1: i32; var v2: i32; - impl as ImplicitAs(Bool) { - fn Convert[me: Self]() -> Bool { + impl as ImplicitAs(bool) { + fn Convert[me: Self]() -> bool { return not (me.v1 == me.v2); } } diff --git a/third_party/examples/re2/re2.carbon b/third_party/examples/re2/re2.carbon index ba40a0491e6d..72f907616bd6 100644 --- a/third_party/examples/re2/re2.carbon +++ b/third_party/examples/re2/re2.carbon @@ -302,7 +302,7 @@ class RE2 { impl as Destroyable; // Returns whether RE2 was created properly. - fn ok[me: Self]() -> Bool { return me.error_code() == ErrorCode.NoError; } + fn ok[me: Self]() -> bool { return me.error_code() == ErrorCode.NoError; } // The string specification for this RE2. E.g. // RE2 re("ab*c?d+");