Skip to content

Conversation

cristianoc
Copy link
Collaborator

Summary\n- annotate parsed expressions with mutable return flags and propagate into the typed tree\n- add a parser-time pass that marks tail positions and expose an accessor for tooling\n- update helpers and add OUnit coverage for return semantics\n\n## Testing\n- dune build\n- dune runtest tests/ounit_tests\n- make

Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
@cristianoc
Copy link
Collaborator Author

@zth I had to write the prompt AND the patch—next time try not to outsource the entire job to your toaster.

@cristianoc
Copy link
Collaborator Author

The magic prompt:

Screenshot 2025-09-18 at 05 00 29

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines 96 to 100
{funct = fn1; args = (Nolabel, a) :: args; partial; transformed_jsx};
pexp_loc = e.pexp_loc;
pexp_attributes = e.pexp_attributes @ f.pexp_attributes;
pexp_is_return = false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Preserve return markers when rewriting application expressions

The new pexp_is_return flag is set by Res_return_marker before the built‑in PPX rewrites applications, but Ast_exp_apply.app_exp_mapper now recreates the expression with pexp_is_return = false unconditionally. Any call expression that passes through this mapper (which is invoked for every Pexp_apply in bs_builtin_ppx) will therefore lose its return annotation even when it was in tail position, so the typed AST never exposes exp_is_return for the common case of let f x = g x. The mapper should carry over the original expression’s flag (and similar for nested cases) rather than resetting it.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@codex see if you can repro the issue in a test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

Testing

  • ⚠️ dune runtest tests/ounit_tests (fails because dune is not available in the container)

View task →

Copy link

pkg-pr-new bot commented Sep 18, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@7898

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@7898

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@7898

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@7898

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@7898

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@7898

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@7898

commit: a39fb92

@cristianoc cristianoc requested a review from zth September 18, 2025 05:48
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