Replace impl fn with override fn (#6008)

This proposal renames the syntax used to mark an overriding definition
of a virtual method from `impl fn` to `override fn` to avoid ambiguity:
besides indicating an overriding virtual function, it can be parsed as
an "impl" declaration when the construct following "impl" begins with a
lambda introduced by "fn".

Closes #5711

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
Elliott Kalt
2025-09-12 23:27:02 +00:00
committed by GitHub
co-authored by Richard Smith
parent 973d721916
commit f4bd6e42f9
17 changed files with 234 additions and 162 deletions
+4 -4
View File
@@ -46,11 +46,11 @@ import Cpp library "abstract.h";
class C {
extend base: Cpp.A;
// CHECK:STDERR: fail_todo_impl_abstract_member.carbon:[[@LINE+4]]:3: error: impl without compatible virtual in base class [ImplWithoutVirtualInBase]
// CHECK:STDERR: impl fn f[addr self: Self*]() {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_todo_impl_abstract_member.carbon:[[@LINE+4]]:3: error: override without compatible virtual in base class [OverrideWithoutVirtualInBase]
// CHECK:STDERR: override fn f[addr self: Self*]() {}
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
impl fn f[addr self: Self*]() {}
override fn f[addr self: Self*]() {}
}
// --- abstract_final.h