Skip to content

Prune dead code in generator and generated support blob #39

Description

@zgimbutas

Found in the July 2026 AI-assisted code review (Claude Code); all verified dead by grep/typechecker analysis.

In the generator:

  • The "three or more dimensions — punt" branch in mex_marshal_array (src/mwrap-cgen.cc) is unreachable: the typechecker rejects >2-D arrays for every array tinfo.
  • mwrap_compat_type_support (~30 lines, commented out) and its commented-out call site in print_mex_init are relics.
  • mw_use_longlong / mw_use_ulonglong are declared extern in src/mwrap-ast.h but defined and referenced nowhere (would be a link error if ever used).

Shipped into every generated MEX via the support blob (src/mwrap-support.c):

  • mxWrapGetP_single, mxWrapCreateP_single, mxWrapStrncpy_single, mxWrapGetString_single are defined but never referenced by any emitted code — dead weight in every generated file and a source of unused-function warnings on some compilers.

In the Python port:

  • TokenType.EOF is never emitted by the lexer, so the EOF branch in Parser.feed is unreachable (end-of-file is handled by finish_file).

Constraints: src/mwrap-support.c and python/mwrap_support.c must stay byte-identical; support-blob removals change every generated file, so best paired with a minor release. Run testing/test_python.sh and the Octave suite after pruning.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions