Skip to content

Simplify parameter validation with compile-time type constraints#89

Merged
ocots merged 1 commit intodevelopfrom
supported_params
Mar 4, 2026
Merged

Simplify parameter validation with compile-time type constraints#89
ocots merged 1 commit intodevelopfrom
supported_params

Conversation

@ocots
Copy link
Copy Markdown
Member

@ocots ocots commented Mar 4, 2026

Replace runtime validation using _supported_parameters() and validate_supported_parameter() with compile-time type constraints directly in struct definitions.

Changes:

  • Update struct definitions to use specific type constraints:
    • CPU-only strategies: P<:CPU (ADNLP, Ipopt, Knitro)
    • CPU+GPU strategies: P<:Union{CPU, GPU} (Exa, MadNLP, MadNCL)
  • Remove _supported_parameters() and validate_supported_parameter() functions
  • Remove validation calls from constructors and metadata() functions
  • Update extensions to remove validation calls
  • Update tests to expect TypeError instead of IncorrectArgument
  • Remove tests for deleted validation functions

Benefits:

  • ~150 lines of code removed
  • Earlier error detection (compile-time vs runtime)
  • Simpler and more robust validation mechanism
  • Clearer intent with type constraints visible in struct definitions

All 2895 tests pass successfully.

Replace runtime validation using _supported_parameters() and
validate_supported_parameter() with compile-time type constraints
directly in struct definitions.

Changes:
- Update struct definitions to use specific type constraints:
  * CPU-only strategies: P<:CPU (ADNLP, Ipopt, Knitro)
  * CPU+GPU strategies: P<:Union{CPU, GPU} (Exa, MadNLP, MadNCL)
- Remove _supported_parameters() and validate_supported_parameter() functions
- Remove validation calls from constructors and metadata() functions
- Update extensions to remove validation calls
- Update tests to expect TypeError instead of IncorrectArgument
- Remove tests for deleted validation functions

Benefits:
- ~150 lines of code removed
- Earlier error detection (compile-time vs runtime)
- Simpler and more robust validation mechanism
- Clearer intent with type constraints visible in struct definitions

All 2895 tests pass successfully.
@ocots ocots merged commit 8e178f6 into develop Mar 4, 2026
8 checks passed
@ocots ocots deleted the supported_params branch March 4, 2026 22:16
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