Skip to content

Reserve keywords - #6416

Merged
Timothee Guerin (timotheeguerin) merged 12 commits into
microsoft:mainfrom
timotheeguerin:reserve-keywords
Mar 13, 2025
Merged

Reserve keywords#6416
Timothee Guerin (timotheeguerin) merged 12 commits into
microsoft:mainfrom
timotheeguerin:reserve-keywords

Conversation

@timotheeguerin

@timotheeguerin Timothee Guerin (timotheeguerin) commented Mar 12, 2025

Copy link
Copy Markdown
Member

fix #6096

Reserve all the keywords we discussed:

Changes from the design approved:

  • added self which might be a better alternative to this
  • dropped base and replaced with super. base was a common name used in our operation test op foo is base so feels it might be as well outside.

Behavior

Errors if used in those cases:

  • declaration name
  • referenced directly as a type reference
  • referenced as the base reference in a member expression

Ok if used in those:

  • model property name
  • enum member name
  • union variant name
  • decorator call expression even if its just @statemachine (differ from the disallowed statemachine reference above)

@azure-sdk

Azure SDK Bot (azure-sdk) commented Mar 12, 2025

Copy link
Copy Markdown
Collaborator

All changed packages have been documented.

  • @typespec/compiler
  • @typespec/http-specs
  • @typespec/openapi3
  • @typespec/protobuf
Show changes

@typespec/compiler - breaking ✏️

Adding new keywords for future use:,> - statemachine,> - macro,> - package,> - metadata,> - env,> - arg,> - declare,> - array,> - struct,> - record,> - module,> - trait,> - this,> - self,> - super,> - keyof,> - with,> - implements,> - impl,> - satisfies,> - flag,> - auto,> - partial,> - private,> - public,> - protected,> - internal,> - sealed,> - local,> - async

@typespec/http-specs - internal ✏️

Reserve keywords

@typespec/openapi3 - internal ✏️

Reserve keywords

@typespec/protobuf - internal ✏️

Reserve keywords

@azure-sdk

Azure SDK Bot (azure-sdk) commented Mar 13, 2025

Copy link
Copy Markdown
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Merged via the queue into microsoft:main with commit 9a4463b Mar 13, 2025
@timotheeguerin
Timothee Guerin (timotheeguerin) deleted the reserve-keywords branch March 13, 2025 22:49
Dmitrii Sedelnikov (dmnorc) pushed a commit to dmnorc/typespec that referenced this pull request Apr 9, 2025
fix microsoft#6096

Reserve all the keywords we discussed:

## Changes from the design approved:
- added `self` which might be a better alternative to `this`
- dropped `base` and replaced with `super`. `base` was a common name
used in our operation test `op foo is base` so feels it might be as well
outside.

## Behavior
Errors if used in those cases:
- declaration name
- referenced directly as a type reference
- referenced as the base reference in a member expression


Ok if used in those:
- model property name
- enum member name
- union variant name
- decorator call expression even if its just `@statemachine` (differ
from the disallowed `statemachine` reference above)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider reserving keywords for upcoming features

3 participants