Skip to content

enable building proper with OTP-29#324

Open
mikpe wants to merge 2 commits intoproper-testing:masterfrom
mikpe:enable-building-proper-with-otp29
Open

enable building proper with OTP-29#324
mikpe wants to merge 2 commits intoproper-testing:masterfrom
mikpe:enable-building-proper-with-otp29

Conversation

@mikpe
Copy link
Copy Markdown

@mikpe mikpe commented Feb 18, 2026

  • eliminate old-style catches
  • resolve is_record/1 ambiguity
  • fix variable exported from subexpression

- eliminate old-style catches
- resolve is_record/1 ambiguity
- fix variable exported from subexpression
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.41%. Comparing base (f511d29) to head (757db6f).
⚠️ Report is 13 commits behind head on master.

Files with missing lines Patch % Lines
src/proper_erlang_abstract_code.erl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #324      +/-   ##
==========================================
+ Coverage   85.27%   85.41%   +0.14%     
==========================================
  Files          14       14              
  Lines        4590     4594       +4     
==========================================
+ Hits         3914     3924      +10     
+ Misses        676      670       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@NelsonVides NelsonVides mentioned this pull request Mar 23, 2026
R = [{M,T,A,proper_typeserver:demo_translate_type(M, stringify(T, A))}
|| {M,T,A} <- MTs],
{OKs,Errors} = lists:partition(fun type_translation_is_ok/1, R),
{[Inst || TGen <- OKs, (Inst = pick_instance(TGen)) =/= ok], length(Errors)}.
Copy link
Copy Markdown
Collaborator

@kostis kostis Mar 24, 2026

Choose a reason for hiding this comment

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

I want to understand the rationale for this change and what exactly is wrong with this code in general and in the upcoming OTP 29. To me, this code besides being "valid Erlang", is perfectly understandable in what it does and how it achieves it. Moreover, it's the last statement in the body of this function, so there is not even a chance that variables will be used after it. So why is it better to have to write a new function of six lines for it?

Also, I've noticed that the release notes for the pre-releases of 29 advertise a "new language feature" that encourages such code. I quote from that page:

By enabling the compr_assign feature, it is now possible to bind variables in a comprehensions. For example: [H || E <- List, H = erlang:phash2(E), H rem 10 =:= 0]

How does the PropEr code differ from this example and what am I missing?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's due to an unfortunate combination of two language changes:

  1. Exporting bindings from subexpressions is deprecated. In this case the lhs of (Inst = ...) =/= ok triggers that. Plain matches don't count as subexpressions.
  2. Previously you could write [Y || X <- L, Y = f(X), predicate(Y)] and it would compile but give a bad filter exception at runtime. The other change, enabled by compr_assign, makes those bindings work.

I've experimented a bit and found a shorter workaround: instead of having a match (Y = f(X)) to bind the intermediate value, use a single-element generator (Y <- [f(X)]). I'm pushing an update with that change.

Copy link
Copy Markdown
Collaborator

@kostis kostis left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I've left a comment concerning one of the changes.

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.

2 participants