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

Accept \ in Windows pathnames in coq_project args #15775

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

jfehrle
Copy link
Member

@jfehrle jfehrle commented Mar 5, 2022

Fix regression from #14558. See here.

FYI: @Columbus240

@jfehrle jfehrle added the kind: fix This fixes a bug or incorrect documentation. label Mar 5, 2022
@jfehrle jfehrle added this to the 8.15.1 milestone Mar 5, 2022
@jfehrle jfehrle requested review from a team as code owners March 5, 2022 23:31
@@ -151,7 +151,8 @@ let check_filename f =
let a = ref None in
let check_char c =
match c with
| '\n' | '\r' | '\t' | '\\' | '\'' | '"' | ' ' | '#' | '$' | '%' -> a := Some c
| '\\' | '$' when Sys.os_type = "Unix" -> a := Some c
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens on macos?

Copy link
Member Author

Choose a reason for hiding this comment

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

I took out $ for now, that likely won't come up too much on Windows. Very hard to test this because the dune build doesn't have a coq_makefile-prelude and building a modified version for Windows is a project (I rarely do this anymore). If it's not a fix, it is at least a step in the right direction.

Copy link
Contributor

@silene silene left a comment

Choose a reason for hiding this comment

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

Since the Makefile generated by coq_makefile assumes that filenames do not contain any backslash, it does not seem to be a good idea to allow them inside _CoqProject.

@herbelin
Copy link
Member

herbelin commented Mar 7, 2022

Shouldn't it be recommended to have _CoqProject independent of the platform? (And in particular to have a common separator for directories independent of the platform?)

@jfehrle
Copy link
Member Author

jfehrle commented Mar 7, 2022

The _CoqProject contains no backslashes:

-R . Jim

./JEF_test.v

When I try to open JEF_test.v in CoqIDE, it tries to read the _CoqProject file. I see this message flashed at the bottom of the CoqIDE window for 5 seconds (easily missed), and the buffer isn't created. (The message should be a lot more visible, noted in #15774.)

image

I expect this is because let f = CUnix.correct_path f' orig_dir in converts the relative path to an absolute path, which would introduce backslashes on Windows.

As I said, I think this is a step forwards and may be a fix, but I'm not going to do any more work on this now.

@herbelin
Copy link
Member

herbelin commented Mar 7, 2022

I expect this is because let f = CUnix.correct_path f' orig_dir in converts the relative path to an absolute path, which would introduce backslashes on Windows.

I see, then, it is maybe enough that the check_filename is done on the f parsed in the _CoqProject file rather than the system-dependent f obtained by calling CUnix.correct_path!

@jfehrle
Copy link
Member Author

jfehrle commented Mar 7, 2022

Indeed, that just occurred to me. I updated the PR to do just that.

@silene
Copy link
Contributor

silene commented Mar 8, 2022

I expect this is because let f = CUnix.correct_path f' orig_dir in converts the relative path to an absolute path

This is not quite correct. Function correct_path just prepends orig_dig to f' if f' is not an absolute path. But orig_dir itself is not an absolute path. In normal uses of coq_makefile, orig_dir should just be . or foo, not an absolute path. But I guess this assumption does not apply to Coqide and that is how an absolute path ends up here.

@jfehrle
Copy link
Member Author

jfehrle commented Mar 8, 2022

@silene Yeah, the routine won't make the path absolute unless the argument is absolute, but I expect it always converts / to \ on Windows, also problematic.

@jfehrle
Copy link
Member Author

jfehrle commented Mar 8, 2022

@herbelin @silene Who can/should be the assignee? I'd like to get this in 8.15.1.

@gares gares assigned gares and unassigned gares Mar 9, 2022
@herbelin herbelin self-assigned this Mar 9, 2022
@herbelin
Copy link
Member

Will merge soon.

@herbelin
Copy link
Member

@coqbot: merge now

@coqbot-app coqbot-app bot merged commit 0247b3d into coq:master Mar 11, 2022
@coqbot-app coqbot-app bot added this to Request 8.15.1 inclusion in Coq 8.15 Mar 11, 2022
@Columbus240
Copy link
Contributor

Fix regression from #14558. See here.

FYI: @Columbus240

Good catch! Thanks for mentioning me.
If I'm not badly mistaken, the commit in this PR doesn't contain any functional change, except the lines with Minilib.log and the Parsing_error. So does this PR, as it is now, really fix the problem?

Comment on lines +254 to +255
| f :: r ->
let abs_f = CUnix.correct_path f orig_dir in
Copy link
Member Author

Choose a reason for hiding this comment

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

@Columbus240 Notice that I renamed the original f' to f, so the check_filename f behaves differently. Right?

If I'm not badly mistaken

Questions from others, even if mistaken, can be quite helpful. So no need to apologize with "badly". I usually make several mistakes before breakfast each day.

Copy link
Contributor

Choose a reason for hiding this comment

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

Both before and after the change, the code does the following (if I interpret it correctly): Take the first element of the list, and apply CUnix.correct_path _ orig_dir to it. Before the change, the first element of the list was called f' and the result was stored in f, after the change the first element of the list is called f and the result is stored in abs_f.
So I don’t see the functional change, because the renaming was done consistently.

Copy link
Contributor

Choose a reason for hiding this comment

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

I find abs_f is a slightly more evocative name, making the meaning of this variable a little more clear. So I have nothing against renaming.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I don’t see the functional change, because the renaming was done consistently.

not quite, see eg line 259 (before PR) https://github.com/coq/coq/pull/15775/files#diff-13482a4486eee3b60cca52baee0cf046a6d89d7d009e314364bce73ee4377effL259

Copy link
Contributor

Choose a reason for hiding this comment

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

Ooh, that makes sense. Thanks for the explanation.

SkySkimmer added a commit to SkySkimmer/coq that referenced this pull request Mar 18, 2022
@SkySkimmer SkySkimmer mentioned this pull request Mar 18, 2022
@coqbot-app coqbot-app bot moved this from Request 8.15.1 inclusion to Shipped in 8.15.1 in Coq 8.15 Mar 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: fix This fixes a bug or incorrect documentation.
Projects
No open projects
Coq 8.15
  
Shipped in 8.15.1
Development

Successfully merging this pull request may close these issues.

None yet

7 participants