Skip to content

Compiler: Return type declarations on user functions (VM + JIT) #205

@PurHur

Description

@PurHur

Problem

Modern PHP web code uses return types:

function slug(string $s): string { ... }

#55 covers non-void returns in JIT; this issue adds declared return type checking/coercion per strict_types (#156).

Goal

Honor : return types on user functions in VM; JIT emits typed returns where possible.

Tasks

  • Read return type from PHPCfg\Func in compileFunction
  • VM: coerce/check return value at TYPE_RETURN
  • JIT: use declared type for LLVM return value
  • PHPT: valid/invalid returns with strict_types=1
  • Void return (): void explicit

Acceptance criteria

Returning wrong type throws TypeError when strict_types enabled.

Dependencies

Files

  • lib/Compiler.php, lib/VM.php, lib/JIT.php

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions