Skip to content

Conversation

@Jds-23
Copy link
Contributor

@Jds-23 Jds-23 commented Dec 18, 2025

#657

  • crates/sema/src/ty/mod.rs

    • Error message for public interface parameter/return types updated to reject types that "contain non-public function pointers" (adds check for Ty::has_internal_function).
  • crates/sema/src/ty/ty.rs

    • Added Ty::has_internal_function() to query a new flag.
    • can_be_exported() now disallows types that contain non-public (internal/private) function pointers.
    • Added a new TyFlags::HAS_INTERNAL_FN bit.
    • Extended TyFlags logic to handle TyKind::FnPtr:
      • If the fn pointer's visibility is non-public, set HAS_INTERNAL_FN.
      • Propagate flags from the fn pointer's parameter and return types (calls add_tys on parameters and returns).
  • crates/sema/src/typeck/checker.rs

    • Added helper is_compile_time_constant() using ConstantEvaluator.
    • check_assign() now enforces rules around assigning types that contain mappings:
      • Disallows assigning storage-containing mapping types unless the lvalue is a local/return variable.
      • Emits an error message for invalid assignments.
    • Added is_local_or_return_variable() to detect when an expr refers to a local or return variable.
    • Variable declaration handling (when visiting variables):
      • Constants must be initialized and initializers must be compile-time constant (emit errors otherwise).
      • Immutable variables must be value types (emit error otherwise).
      • State variables containing mappings cannot have initializers (emit error).
      • Non-state variables in calldata/memory that contain mappings are rejected (emit error, instructing the type is only valid in storage).
      • Preserves prior expect_ty check for initializers when present.

@Jds-23 Jds-23 marked this pull request as ready for review December 27, 2025 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant