Skip to content

Function is a built-in identifier, but no error is emitted when it is used to name a type #45703

@eernstg

Description

@eernstg

Consider the following programs:

class Function {}
class C<Function> {}
void main() {}
typedef Function = int;
typedef F<Function> = int;
void main() {}
extension Function on List {}
extension E<Function> on List<Function> {}
void main() {}
mixin Function {}
mixin M<Function> implements List<Function> {}
void main() {}

The word Function is a built-in identifier, but it is not consistently reported as an error when this word is used as the name of a type (that is, a class, type parameter, type alias, etc.).

No errors or other diagnostics are emitted except for the following:

  • The analyzer hints that a class named Function is deprecated.
  • The analyzer and the CFE emit an error "'Function' can't be used as an identifier because it's a keyword" on typedef Function = int;.

All declaring occurrences of Function should be marked as a compile-time error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Epicarea-metaCross-cutting, high-level issues (for tracking many other implementation issues, ...).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions