Skip to content

[Merged by Bors] - feat: unrestricted character set in unicode linter#39796

Closed
thorimur wants to merge 7 commits into
leanprover-community:masterfrom
thorimur:caution-emoji-maybe
Closed

[Merged by Bors] - feat: unrestricted character set in unicode linter#39796
thorimur wants to merge 7 commits into
leanprover-community:masterfrom
thorimur:caution-emoji-maybe

Conversation

@thorimur

@thorimur thorimur commented May 25, 2026

Copy link
Copy Markdown
Contributor

This PR creates the unrestricted array in the unicode linter, which contains characters that have no restrictions on which selector they are followed by, and are not enforced to be followed by any selector at all.

We include '⚠' in it to allow ⚠️. We don't want to ban the text version (), as this is used in lake output (without the text selector) and so may conceivably be mentioned in a comment.

We plan to use ⚠️ in #38126.


Open in Gitpod

@thorimur
thorimur marked this pull request as ready for review May 25, 2026 00:12
@thorimur thorimur changed the title feat: maybeEmojis and ⚠️ in unicode linter feat: maybeEmojis in unicode linter May 25, 2026
@github-actions github-actions Bot added the t-linter Linter label May 25, 2026
@github-actions

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown

PR summary 5f7a90dd94

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ unrestricted

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.


No changes to strong technical debt.
No changes to weak technical debt.

Comment thread Mathlib/Tactic/Linter/TextBased/UnicodeLinter.lean Outdated
@grunweg

grunweg commented May 25, 2026

Copy link
Copy Markdown
Contributor

Thanks for the fix! Can you update the PR description to say what maybeEmojis does (right now, you have to read the diff... which is not ideal). With that, I'm happy to maintainer merge.

@adomasbaliuka

adomasbaliuka commented May 25, 2026

Copy link
Copy Markdown
Collaborator

The current status is that maybeEmojis can be followed by either selector, as well as no selector (right?). Wouldn't we want to enforce that some selector is used?

@thorimur

thorimur commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

The current status is that maybeEmojis can be followed by either selector, as well as no selector (right?). Wouldn't we want to enforce that some selector is used?

I was uncertain about this, thanks for bringing it up. :) The issue is that neither the keyboard shortcut \warning for nor the lake output including actually includes the text selector. (Nor is it present in the mathlib python scripts that use it.) So I'm not sure if the text selector should be introduced in those places, or if the intended meaning there is in fact "let the renderer decide".

@adomasbaliuka

adomasbaliuka commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Let's also ask our expert on Unicode variant selectors @joneugster
My understanding was that we want selectors everywhere, following arguments in, e.g., leanprover/lean4#5015

@thorimur

thorimur commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

Sounds good, let's wait for him. :) I'll also mention this zulip thread I started in case we want further discussion on this specific issue, as well as the zulip thread mentioned in the RFC for convenience.

@JovanGerb JovanGerb removed their assignment May 26, 2026

@joneugster joneugster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks reasonable to lift restrictions on certain characters, thanks!

]

/-- Unicode symbols in mathlib that have no restrictions on which selector they are followed by. -/
public def maybeEmojis : Array Char := #[

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so these are allowed to have either variant-selector (text/emoji) or none at all, aren't they?

maybe there is a better name for it? somehow the name suggests to me that it must have a selector, but it's optional which one.

Docstring might need to reflect that "no selector" is allowed, too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, maybe unrestricted or unrestrictedChars?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've tried out unrestricted (and moved it down below, since now it's not emoji-related per se), let me know what you think :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good imo

Comment thread Mathlib/Tactic/Linter/TextBased.lean Outdated
@thorimur thorimur changed the title feat: maybeEmojis in unicode linter feat: unrestricted character set in unicode linter May 26, 2026
@joneugster

Copy link
Copy Markdown
Contributor

Let's also ask our expert on Unicode variant selectors @joneugster My understanding was that we want selectors everywhere, following arguments in, e.g., leanprover/lean4#5015

Variant selector do make it easier to display emojis correctly. However, adding them might potentially also bring other issues and might not be worth the time for lean4 core. Especially, what lean4 does is outside our reach (as mathlib contributors) and we should work with what we get from core.

@joneugster joneugster self-assigned this May 26, 2026

@joneugster joneugster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is a test file which tests that emojis and non-emojis have an empty intersection. Could you add two more tests ensuring this for the new unrestricted

@joneugster joneugster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

maintainer merge

@thorimur

thorimur commented May 26, 2026

Copy link
Copy Markdown
Contributor Author

Hmm, weird that maintainer merge did not apply the label here...maybe because github identified a merge conflict when it was applied? MathlibTest/LintStyle.lean was renamed to MathlibTest/TextBased.lean, and github said I must resolve these changes. Though, git merge upstream/master did not force me to resolve any conflict, which is maybe why merge-conflict did not get applied... 🤔 Strange.

@grunweg

grunweg commented May 26, 2026

Copy link
Copy Markdown
Contributor

Let me merge this PR, then the above issue is moot :-)
Seriously: we have several reviewers agreeing on this change being desirable (I concur); the implementation looks good to me, and this is blocking another linter - let's get this in. Thanks for addressing this!
bors merge

mathlib-bors Bot pushed a commit that referenced this pull request May 26, 2026
This PR creates the `unrestricted` array in the unicode linter, which contains characters that have no restrictions on which selector they are followed by, and are not enforced to be followed by any selector at all.

We include `'⚠'` in it to allow `⚠️`. We don't want to ban the text version (`⚠`), as this is used in lake output (without the text selector) and so may conceivably be mentioned in a comment.

We plan to use `⚠️` in #38126.
@mathlib-triage mathlib-triage Bot added the ready-to-merge This PR has been sent to bors. label May 26, 2026
@mathlib-bors

mathlib-bors Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat: unrestricted character set in unicode linter [Merged by Bors] - feat: unrestricted character set in unicode linter May 26, 2026
@mathlib-bors mathlib-bors Bot closed this May 26, 2026
b-mehta pushed a commit to b-mehta/mathlib4 that referenced this pull request Jun 2, 2026
…unity#39796)

This PR creates the `unrestricted` array in the unicode linter, which contains characters that have no restrictions on which selector they are followed by, and are not enforced to be followed by any selector at all.

We include `'⚠'` in it to allow `⚠️`. We don't want to ban the text version (`⚠`), as this is used in lake output (without the text selector) and so may conceivably be mentioned in a comment.

We plan to use `⚠️` in leanprover-community#38126.
Bergschaf pushed a commit to Bergschaf/mathlib4 that referenced this pull request Jun 3, 2026
…unity#39796)

This PR creates the `unrestricted` array in the unicode linter, which contains characters that have no restrictions on which selector they are followed by, and are not enforced to be followed by any selector at all.

We include `'⚠'` in it to allow `⚠️`. We don't want to ban the text version (`⚠`), as this is used in lake output (without the text selector) and so may conceivably be mentioned in a comment.

We plan to use `⚠️` in leanprover-community#38126.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors. t-linter Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants