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

Unable to build Dlangide #398

Open
leh103 opened this issue Jan 12, 2019 · 18 comments
Open

Unable to build Dlangide #398

leh103 opened this issue Jan 12, 2019 · 18 comments

Comments

@leh103
Copy link
Contributor

leh103 commented Jan 12, 2019

Got multiple errors when building dlangide on 64 bit Linux using dub and dmd 1.084

@Kokokokoka
Copy link

/opt/dmd-2.084/import/std/functional.d-mixin-215(215,35): Error: module std.ascii is not accessible here, perhaps add static import std.ascii;
/opt/dmd-2.084/import/std/algorithm/iteration.d(3399,28): Error: template instance `std.functional.F!(" a && (b == '_' || b == '-' || std.ascii.isAlphaNum(b)) ", "a", "b").binaryFun!(bool, dchar)` error instantiating
/opt/dmd-2.084/import/std/algorithm/iteration.d(3363,32):        instantiated from here: reduceImpl!(false, string, bool)
/opt/dmd-2.084/import/std/algorithm/iteration.d(3347,33):        instantiated from here: reducePreImpl!(string, bool)
/home/w520/src/dlangide/src/dlangide/workspace/project.d(937,78):        instantiated from here: reduce!(bool, string)
/opt/dmd-2.084/import/std/functional.d-mixin-215(215,23): Error: module std.ascii is not accessible here, perhaps add static import std.ascii;
/opt/dmd-2.084/import/std/algorithm/iteration.d(3399,28): Error: template instance `std.functional.F!(" a && (b == '_' || std.ascii.isAlphaNum(b)) ", "a", "b").binaryFun!(bool, dchar)` error instantiating
/opt/dmd-2.084/import/std/algorithm/iteration.d(3363,32):        instantiated from here: reduceImpl!(false, string, bool)
/opt/dmd-2.084/import/std/algorithm/iteration.d(3347,33):        instantiated from here: reducePreImpl!(string, bool)
/home/w520/src/dlangide/src/dlangide/workspace/project.d(943,66):        instantiated from here: reduce!(bool, string)
/opt/dmd-2.084/import/std/functional.d-mixin-215(215,47): Error: module std.ascii is not accessible here, perhaps add static import std.ascii;
/opt/dmd-2.084/import/std/algorithm/iteration.d(3399,28): Error: template instance `std.functional.F!(" a && (b == '_' || b == '.' || b == '-' || std.ascii.isAlphaNum(b)) ", "a", "b").binaryFun!(bool, dchar)` error instantiating
/opt/dmd-2.084/import/std/algorithm/iteration.d(3363,32):        instantiated from here: reduceImpl!(false, string, bool)
/opt/dmd-2.084/import/std/algorithm/iteration.d(3347,33):        instantiated from here: reducePreImpl!(string, bool)
/home/w520/src/dlangide/src/dlangide/workspace/project.d(949,90):        instantiated from here: reduce!(bool, string)

@leh103
Copy link
Contributor Author

leh103 commented Jan 14, 2019

Yes, this is the exact error I had. BTW It compiled on my 64 bit windows 7 laptop. However, the dmd compiler on that computer has not been upgraded and is running the version 2.083.0. Although, I do not know for sure if the cause is in the compiler, in phobos or in dlang. I took a look at the three lines in the dlang project.d file. It appears to be all the same error. I am not familiar enough with mixins to know for sure how to fix it. Does anyone have any ideas?

@siladi
Copy link

siladi commented Jan 25, 2019

On dmd 2.084.0-0 I fixed it by editing /usr/include/dmd/phobos/std/functional.d and adding in

import std.ascii;

Compile fine, runs fine.

@leh103
Copy link
Contributor Author

leh103 commented Jan 27, 2019

I thought of that one also. However, it only fixes it for the single individual. It would be better I think to fix it in the dlangide package file "project.d". I will eventually try to do that since I do have a local clone of the github repository. I am reserving the fix by modifying the /usr/include/dmd/phobos/std/functional.d file as a secondary plan.

@leh103
Copy link
Contributor Author

leh103 commented Jan 27, 2019

I really feel it would be best the fix the three nearly identical functions in the repositories file dlangide/src/dlangide/workspace/project.d. I don't know much about templates or mixin but I will try it in my local repository, test the change in linux and windows 7 and then seeing if buggins whats to include the changes. Or maybe someone will fix it before I get to it.

@HugoHugoson
Copy link

HugoHugoson commented Feb 6, 2019

I replaced
std.ascii.isAlphaNum(b)
in the three isValidX functions in ./dlangide/workspace/project.d with
function bool(dchar c) {import std.ascii : isAlphaNum; return isAlphaNum(c);}

Seems to work.
Edit:
Or not. Compiles, but some unittests fail.

Edit 2:
This replacement passes the unittests:
(b > 47 && b < 58) || (b > 64 && b < 91) || (b > 96 && b < 123)

@leh103
Copy link
Contributor Author

leh103 commented Feb 6, 2019

I fixed it by adding the import std,.ascii : isAlpaNum to the top of the project.d file then using a lambda instead of the mixin in the three functions. Like this:
module dlangide.workspace.project;

import dlangide.workspace.workspace;
import dlangide.workspace.projectsettings;
import dlangui.core.logger;
import dlangui.core.collections;
import dlangui.core.settings;
import std.algorithm;
import std.array : empty;
import std.file;
import std.path;
import std.process;
import std.utf;
import std.ascii : isAlphaNum;

// return reduce!q{ a && (b == '' || b == '-' || std.ascii.isAlphaNum(b)) }(true, s);
return reduce!((a, b) => a && (b == '
' || b == '-' || isAlphaNum(b)))(true, s);

// return reduce!q{ a && (b == '_' || std.ascii.isAlphaNum(b)) }(true, s);
return reduce!((a, b) => a && (b == '_' || isAlphaNum(b)))(true, s);

// return reduce!q{ a && (b == '_' || b == '.' || b == '-' || std.ascii.isAlphaNum(b)) }(true, s);
return reduce!((a, b) => a && (b == '_' || b == '.' || b == '-' || isAlphaNum(b)))(true, s);

It compiles and runs on Linux. I have not tried compiling on Windows 7 yet and I have not tried the unitest yet. Both are on my "todo" list. Probably be doing that tomorrow.

@leh103
Copy link
Contributor Author

leh103 commented Feb 6, 2019

Sorry the changes to the first function did not paste as code, but you still get the idea I hope.

@leh103
Copy link
Contributor Author

leh103 commented Feb 7, 2019

The result of running "dub test" in the Dlangide folder was:
All unit tests have been run successfully.

I may not have time to test it in Win 7 today and I do not normally do development on my Win 10 machine, so I would have to install dmd and dub on it to test.

@leh103
Copy link
Contributor Author

leh103 commented Feb 13, 2019

I am sorry that it has taken me so long to check it on a Windows 7 computer. But at first it didn't compile because of a different error. The error happened because in the time it took between building on Linux and building on Windows the emsi-container developers changed the library to fix an issue with the LDC compiler. The LDC fix broke the windows Dlangide build when I tried on Windows 7. There is a pull request to fix the Windows version, but I do not know if has been committed and released yet, but I implemented the change in my local repository of emsi-containers and Dlangide builds OK on Windows 7. For some reason it will not build and run the default test because of 16 unresolved linking errors. I
think caused by importing something for the unitests that is not imported for a debug or release build. I am still looking for the cause.
If you need to know the emsi-containers lib version alpha11 builds on Linux and windows OK with dmd but not ldc, emsi-containers version alpha12 builds on Linux but not Windows and emsi-containers version 0.8.0-alpha13 (I assume will be released) will build Dlangide on Linux and Windows with dmd and ldc.

@leh103
Copy link
Contributor Author

leh103 commented Feb 13, 2019

Now since I am unfamiliar with the protocol of what to do next. We have two viable solutions and I am unsure how to proceed. Do I submit a pull request and which solution do we offer to be committed by buggins.

@leh103
Copy link
Contributor Author

leh103 commented Feb 17, 2019

I don't normally use git. I normally just fetch it with dub. However, I do have a Git Manual so I am willing to try and clone the repository and submit a pull request. I like my solution although HugoHugoson's second also works at least for ascii characters. I do not know unicode since it was before my time so I do not know if it would work in other languages.
I just need to know what everyone else whats to do as a fix and I will submit the pull request.

@leh103
Copy link
Contributor Author

leh103 commented Feb 20, 2019

I checked the phobos documentation and std.ascii : isAlphaNum returns true for ascii characters and false for unicode characters. Duh it is in the name std.ascii, but I had to check it to make sure. Blame it on my OCD. I did think of another way to fix this based on HugoHugoson's first idea.

// a private helper function
private bool alphaNumTest(dchar ch) {
import std.ascii : isAlphaNum;
return isAlphaNum(ch);
}

// then replace the std.ascii.isAlphaNum(b) in the 3 mixins with
alphaNumTest(b)

It should work and has the advantage that it retains the use of the string mixins and does not use lambda functions, since Vadim I assume choose string mixins over lambda functions for a reason. I havn't tested this solution yet but I have forked and cloned the repository preparing to make a pull request.

What does everyone else think?

@DreadKyller
Copy link

I'd say as long as you test if feel free, they can always decline it if it's not what they want. However I'd really think it'd be great if the people who run this project would give some form of response considering this isn't exactly a small issue, it prevents some people entirely from compiling.

I tried your proposed solution and I just get "Error: undefined identifier alphaNumTest so until something is done that works I'm using HugoHugoson's second edit, the (b > 47 && b < 58) || (b > 64 && b < 91) || (b > 96 && b < 123)

@leh103
Copy link
Contributor Author

leh103 commented Feb 27, 2019

I agree about the lack of responses by the project manager on the issues.
The alphaNumTest() idea was just a thought of how to make HugoHugoson's first edit work. I never actually tried it. There was some commits on the issue of function string mixins on the Dlang learn forum. I quote the relevant part here:

"I wish to sort an array by calling a template function on a struct. In essence I want to do

foos.sort!("a.get!Dummy < b.get!Dummy");

but I get the error message

/dlang/dmd/linux/bin64/../../src/phobos/std/functional.d-mixin-215(215): Error: undefined identifier Dummy

Is there anyway I can get sort to recognise my Dummy type?

Example: https://run.dlang.io/is/9zDfdd

foos.sort!((a,b) => a.get!Dummy < b.get!Dummy);

String functions can't access the local scope, and thus can't see Dummy. Using lambdas works.

A additional comment was added by another person

They're actually still useful in cases where you need to compare lambdas
(since you can't compare actual lambdas, but you can compare strings), and
in some cases, using a string lambda with a function that accepts it is less
verbose than using a regular lambda, but in general, folks do tend to use
regular lambdas now that we have the more concise lambda syntax - especially
since string lambdas do have some annoying limitations like this."

Notice that the error message is simular to yours and is on the same phobos file as the one that starts the function trace for this issues error also.
I was preparing the pull request for this issue when I noticed that someone else commented on this post, so thanks for your input.

@MikePryadko
Copy link

MikePryadko commented Sep 30, 2019

I still have problem.

$ dmd --version
DMD64 D Compiler v2.088.0
Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright
$ dub --version
DUB version 1.17.0, built on Sep  1 2019

Can not build - here's log file
Looks like it's Phobo's bug - am I right?

@leh103
Copy link
Contributor Author

leh103 commented Sep 30, 2019

I am not sure it is a Phobo's bug per se. In my research of this problem I found that you can not put a reference to an import in a string mixin like the developer did, because the string mixin does not have access to the scope outside itself. I just rewrote the string mixins into a lambda function as in a previous post on this issue. (see above). It is my understanding that the developer merged the pull request that fixed this issue. Perhaps you have an older version and need to fetch again with dub or clone it again with git which ever method you are most familiar with. According to your file log.txt this is exactly the error I had so the fix to the project workspace.d should work.

@Siemargl
Copy link

Siemargl commented Aug 22, 2020

Better fix in a PR#409
#410

Checked @ Win32, dmd 2.092.1

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 a pull request may close this issue.

7 participants