Skip to content

E2xxx: Semantic analysis errors ​

This page is generated by scripts/docs/gen-error-code-docs.py from the define_codes! registry in src/util/diagnostic/codes/ and locales/en.json. Do not edit it by hand. Change the wording in locales/*.json, change the code table in define_codes!, then rerun python scripts/docs/gen-error-code-docs.py.

Errors produced during semantic analysis, covering scopes, variable lifetimes, ownership, and function signature resolution.

This family holds 23 codes, all registered in the define_codes! registry, with the category Semantic. See the error code index for the complete inventory.

Code Overview ​

CodeNameCategoryspan exemptTemplateEmission sites
E2001Scope errorSemanticNoVariable '{name}' is not in scope⚠ Not yet emitted
E2002Duplicate definitionSemanticNoredefinition: '{name}' is already defined in the current scope✅ 4 sites
E2003Ownership errorSemanticNoownership constraint violated: {reason}✅ 1 site
E2010Immutable assignmentSemanticNocannot assign to immutable variable '{name}'✅ 2 sites
E2011Use of uninitialized variableSemanticNouse of uninitialized variable '{name}'⚠ Not yet emitted
E2012Mutability ConflictSemanticNoMutability conflict: cannot use mutable reference in immutable context⚠ Not yet emitted
E2013Variable ShadowingSemanticNoCannot shadow existing variable '{name}'✅ 3 sites
E2014Use of moved valueSemanticNo'{name}' has been moved and cannot be used again✅ 1 site
E2016Immutable assignmentSemanticNoCannot assign to immutable variable '{name}'✅ 1 site
E2018Mutable/immutable borrow conflictSemanticNoCannot mutable borrow '{name}' (already immutably borrowed)✅ 1 site
E2019Double freeSemanticNoValue '{name}' was freed twice✅ 1 site
E2020Use after freeSemanticNo'{name}' is used after being freed✅ 1 site
E2027Unsafe dereferenceSemanticNoCannot dereference a raw pointer outside of an unsafe block✅ 1 site
E2029Reference cycle in spawnSemanticNoReference cycle in spawn: {cycle}✅ 1 site
E2030Refinement type constraint violationSemanticNoAfter assigning to '{assigned}', '{var}' no longer satisfies the refinement type constraint: {constraint} (counterexample: {counterexample})✅ 1 site
E2031Refinement constraint cannot be provenSemanticNoAfter assigning to '{assigned}', the refinement type constraint on '{var}': {constraint} cannot be statically proven within the proof kernel✅ 3 sites
E2090Invalid SignatureSemanticNoInvalid signature: {reason}✅ 3 sites
E2091Unknown Type in SignatureSemanticNoInvalid signature: unknown type '{type_name}'⚠ Not yet emitted
E2092Signature Missing ArrowSemanticNoInvalid signature: missing '->'✅ 1 site
E2093Duplicate Parameter NameSemanticNoInvalid signature: duplicate parameter name '{name}'✅ 2 sites
E2094Generic Parameter ShadowingSemanticNoInvalid signature: generic parameter '{name}' shadows an outer generic parameter⚠ Not yet emitted
E2095Parameter name shadows generic parameterSemanticNoInvalid signature: parameter name '{name}' shadows a generic parameter✅ 1 site
E2096Bare container type in signatureSemanticNoInvalid signature: container type '{name}' is missing type arguments✅ 1 site

Code Details ​

E2001: Scope error ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::variable_not_in_scope(name)
  • Template: Variable '{name}' is not in scope
  • Message: Variable is not in the current scope
  • Help: Check the variable's scope and make sure it is accessible here
  • Emission site: ⚠ Not yet emitted (the registry retains the code, but non-test code never calls it, so users cannot trigger it)
  • Source comment name: 变量不在作用域中

E2002: Duplicate definition ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::duplicate_definition(name)
  • Template: redefinition: '{name}' is already defined in the current scope
  • Message: Variable is defined multiple times in the same scope
  • Help: rename or remove the duplicate definition
  • Emission sites: src/frontend/core/sema/checker.rs:1816, src/frontend/core/sema/inference/expressions/stmt_walk.rs:373, src/frontend/core/sema/inference/statements/fn_def.rs:769 and 4 more sites
  • Source comment name: 重复定义

E2003: Ownership error ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::ownership_violation(reason)
  • Template: ownership constraint violated: {reason}
  • Message: ownership constraint not satisfied
  • Help: check the ownership semantics of the value
  • Emission sites: src/frontend/core/sema/proof/verdict.rs:303
  • Source comment name: 所有权约束违反

E2010: Immutable assignment ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::immutable_assignment(name)
  • Template: cannot assign to immutable variable '{name}'
  • Message: attempted to modify an immutable variable
  • Help: use 'mut' to declare a mutable variable
  • Emission sites: src/frontend/core/sema/inference/expressions/stmt_walk.rs:368, src/frontend/core/sema/inference/statements/stmt.rs:821
  • Source comment name: 不可变赋值

E2011: Use of uninitialized variable ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::uninitialized_variable(name)
  • Template: use of uninitialized variable '{name}'
  • Message: used an uninitialized variable
  • Help: initialize the variable before use
  • Emission site: ⚠ Not yet emitted (the registry retains the code, but non-test code never calls it, so users cannot trigger it)
  • Source comment name: 使用未初始化变量

E2012: Mutability Conflict ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::mutability_conflict()
  • Template: Mutability conflict: cannot use mutable reference in immutable context
  • Message: Mutable reference used in immutable context
  • Help: Ensure the reference's mutability matches the usage context
  • Emission site: ⚠ Not yet emitted (the registry retains the code, but non-test code never calls it, so users cannot trigger it)
  • Source comment name: 可变性冲突

E2013: Variable Shadowing ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::variable_shadowing(name)
  • Template: Cannot shadow existing variable '{name}'
  • Message: Cannot shadow existing variable
  • Help: Use a different variable name, or declare the variable in a different scope
  • Emission sites: src/frontend/core/sema/inference/expressions/stmt_walk.rs:378, src/frontend/core/sema/inference/statements/stmt.rs:835, src/frontend/core/sema/inference/statements/stmt.rs:935
  • Source comment name: 变量遮蔽

E2014: Use of moved value ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::use_after_move(name)
  • Template: '{name}' has been moved and cannot be used again
  • Help: The value has been moved to a new owner. To use it again, use a reference or clone.
  • Emission sites: src/frontend/core/sema/proof/verdict.rs:251
  • Source comment name: 使用已移动的变量

E2016: Immutable assignment ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::immutable_assign(name)
  • Template: Cannot assign to immutable variable '{name}'
  • Help: Use mut to declare the variable to allow assignment.
  • Emission sites: src/frontend/core/sema/proof/verdict.rs:281
  • Source comment name: 不可变赋值(所有权检查器用)

E2018: Mutable/immutable borrow conflict ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::mutable_immutable_borrow_conflict(name)
  • Template: Cannot mutable borrow '{name}' (already immutably borrowed)
  • Help: Ensure no immutable references exist before creating a mutable reference.
  • Emission sites: src/frontend/core/sema/proof/verdict.rs:241
  • Source comment name: 可变/不可变借用冲突

E2019: Double free ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::double_drop(name)
  • Template: Value '{name}' was freed twice
  • Help: Ensure the value is freed only once.
  • Emission sites: src/frontend/core/sema/proof/verdict.rs:271
  • Source comment name: 双重释放

E2020: Use after free ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::use_after_drop(name)
  • Template: '{name}' is used after being freed
  • Help: Use the value before it is freed, or refactor the code.
  • Emission sites: src/frontend/core/sema/proof/verdict.rs:261
  • Source comment name: 释放后使用

E2027: Unsafe dereference ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::unsafe_deref()
  • Template: Cannot dereference a raw pointer outside of an unsafe block
  • Help: Wrap the dereference operation in an unsafe block.
  • Emission sites: src/frontend/core/sema/proof/verdict.rs:288
  • Source comment name: unsafe 解引用

E2029: Reference cycle in spawn ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::spawn_ref_cycle(cycle)
  • Template: Reference cycle in spawn: {cycle}
  • Message: References forming a cycle were detected inside the spawn block
  • Help: References captured by spawn must not form a cyclic dependency; please check the capture list
  • Emission sites: src/frontend/core/sema/proof/verdict.rs:296
  • Source comment name: spawn 内 ref 循环

E2030: Refinement type constraint violation ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::refined_constraint_violated(assigned, var, constraint, counterexample)
  • Template: After assigning to '{assigned}', '{var}' no longer satisfies the refinement type constraint: {constraint} (counterexample: {counterexample})
  • Help: A refinement type annotation requires the dependent variable to still satisfy the predicate constraint after the related assignments. Please adjust the assignments so that the constraint holds, or relax the type annotation.
  • Emission sites: src/frontend/core/sema/checker/refinement.rs:703
  • Source comment name: 精化类型约束违反(赋值后依赖变量 VC 被 SMT 证伪——

E2031: Refinement constraint cannot be proven ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::refined_unproven(assigned, var, constraint)
  • Template: After assigning to '{assigned}', the refinement type constraint on '{var}': {constraint} cannot be statically proven within the proof kernel
  • Help: RFC-027 requires all refinement constraints to be proven at compile-time—failure to prove is a compile error. Rewrite the constraint so its arguments can be statically evaluated (literals or expressions foldable to literals), or provide a proof function returning Type to participate in compile-time execution.
  • Emission sites: src/frontend/core/sema/checker.rs:172, src/frontend/core/sema/checker/refinement.rs:724, src/frontend/core/sema/checker/refinement.rs:855
  • Source comment name: 精化约束无法证明(RFC-027 §4/§9:Unproven → 编译错误 + 未解命题,

E2090: Invalid Signature ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::invalid_signature(reason)
  • Template: Invalid signature: {reason}
  • Message: Failed to parse function signature
  • Help: Check that the function signature format is correct
  • Emission sites: src/frontend/core/sema/signature.rs:59, src/frontend/core/sema/signature.rs:64, src/frontend/core/sema/signature.rs:536
  • Source comment name: 签名解析失败(通用)

E2091: Unknown Type in Signature ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::invalid_signature_unknown_type(type_name)
  • Template: Invalid signature: unknown type '{type_name}'
  • Message: Signature contains unknown type
  • Help: Use a valid type, e.g., '(T) -> T' for function parameters
  • Emission site: ⚠ Not yet emitted (the registry retains the code, but non-test code never calls it, so users cannot trigger it)
  • Source comment name: 未知类型

E2092: Signature Missing Arrow ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::invalid_signature_missing_arrow()
  • Template: Invalid signature: missing '->'
  • Message: Signature is missing '->'
  • Help: Ensure the signature format is '(parameter list) -> return type'
  • Emission sites: src/frontend/core/sema/signature.rs:72
  • Source comment name: 缺少箭头

E2093: Duplicate Parameter Name ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::invalid_signature_duplicate_param(name)
  • Template: Invalid signature: duplicate parameter name '{name}'
  • Message: Signature contains duplicate parameter name
  • Help: Ensure each parameter name is unique
  • Emission sites: src/frontend/core/sema/signature.rs:52, src/frontend/core/sema/signature.rs:85
  • Source comment name: 重复参数名

E2094: Generic Parameter Shadowing ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::invalid_signature_generic_shadows(name)
  • Template: Invalid signature: generic parameter '{name}' shadows an outer generic parameter
  • Message: Generic parameter shadows outer generic parameter
  • Help: Use a different generic parameter name for the inner function type
  • Emission site: ⚠ Not yet emitted (the registry retains the code, but non-test code never calls it, so users cannot trigger it)
  • Source comment name: 泛型参数遮蔽

E2095: Parameter name shadows generic parameter ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::invalid_signature_param_shadows_generic(name)
  • Template: Invalid signature: parameter name '{name}' shadows a generic parameter
  • Message: Parameter name conflicts with a generic parameter
  • Help: Parameter names cannot match generic parameter names
  • Emission sites: src/frontend/core/sema/signature.rs:93
  • Source comment name: 参数名遮蔽泛型

E2096: Bare container type in signature ​

  • Category: Semantic
  • span exempt: No
  • Constructor: ErrorCodeDefinition::invalid_signature_bare_container(name)
  • Template: Invalid signature: container type '{name}' is missing type arguments
  • Message: Container type in signature is missing type arguments
  • Help: Container types are generic type constructors (SPEC type-system §4.1.1); a bare name is not a valid type expression. Write them in parameterized form: List(T), Dict(K, V), Vec(T), Array(T, N), Set(T), Tuple(T, ...)
  • Emission sites: src/frontend/core/sema/signature.rs:529
  • Source comment name: 签名裸容器类型(#391:容器是泛型构造器,SPEC §4.1.1,构造期拒绝)