Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format: More refined check to evaluate whether a box shall lead to go beyond max_indent and need a break prior to opening? #7807

Open
vicuna opened this issue Jun 11, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@vicuna
Copy link

commented Jun 11, 2018

Original bug ID: 7807
Reporter: herbelin
Status: new
Resolution: open
Priority: normal
Severity: feature
Version: 4.06.1
Category: standard library
Related to: #7862
Monitored by: ralfj @gasche @yakobowski

Bug description

This is a followup of a discussion at issue 7804 showing the example of a box which would fit on the line but which however forces a break just because it is opened beyond the max_indent limit.

Assuming that the specification of max_indent is strictly to not indent beyond the max_indent value, the test made at box opening to force a break if the box is opened beyong max_indent seems overly preventive. Opening a box does not mean that printing the contents of the box shall necessarily need to break a line and indent.

In particular, in a situation such as described in coq/coq#7731, where a box is opened beyond the max_indent limit but this box is within a surrounding box and a previous break in the surrounding box has already checked that the forthcoming comments shall fit, the box may (??) trust the decision take by the previous break and not test max_indent. Would it make sense to refine the algorithm in this way? Otherwise said, looking at the implementation of Format.format_pp_token, is the "size" computed in the Pp_break clause correct enough to ensure that, if it fits, forthcoming boxes shall fit and shall not have to preventively test whether they are beyond the max_indent limit.

Steps to reproduce

See #7804 for a simplified example, or coq/coq#7731 for a realistic example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.