[Compile Time Values] Add syntactic verification of valid expressions in '@const' contexts

Syntactically verify that initializer expressions of '@const' variables and argument expressions to '@const' parameters consist strictly of syntactically-verifiable set of basic values and operations
This commit is contained in:
Artem Chikin
2025-04-15 15:37:02 -07:00
parent abcc134621
commit d8176a7e89
36 changed files with 582 additions and 18 deletions

View File

@@ -816,9 +816,34 @@ ERROR(cannot_return_value_from_void_func,none,
NOTE(add_return_type_note,none,
"did you mean to add a return type?", ())
ERROR(expect_compile_time_const,none,
ERROR(expect_compile_time_literal,none,
"expect a compile-time constant literal", ())
ERROR(const_unsupported_enum_associated_value,none,
"enums with associated values not supported in a '@const' expression", ())
ERROR(const_unsupported_operator,none,
"unsupported operator in a '@const' expression", ())
ERROR(const_unsupported_type,none,
"unsupported type in a '@const' expression", ())
ERROR(const_unsupported_type_expr,none,
"type expressions not supported in a '@const' expression", ())
ERROR(const_unsupported_closure,none,
"closures not supported in a '@const' expression", ())
ERROR(const_unsupported_keypath,none,
"keypaths not supported in a '@const' expression", ())
ERROR(const_opaque_decl_ref,none,
"unable to resolve variable reference in a '@const' expression", ())
ERROR(const_opaque_func_decl_ref,none,
"unable to resolve function reference in a '@const' expression", ())
ERROR(const_non_convention_c_conversion,none,
"only 'convention(c)' function values are supported in a '@const' expression", ())
ERROR(const_opaque_callee,none,
"unable to resolve callee in a '@const' expression", ())
ERROR(const_non_const_param,none,
"reference to a non-'@const' parameter in a '@const' expression", ())
ERROR(const_unknown_default,none,
"not supported in a '@const' expression", ())
//------------------------------------------------------------------------------
// MARK: Import Resolution
//------------------------------------------------------------------------------