Closed rempas closed 2 years ago
Should be fixed with 0e7000148a0d0c76a441bdc9d25ae21dedfc3af5. Also, did you run the latest version of the compiler?
At the time of writing this, the last commit wasn't out so even If I wanted, I couldn't try it, lol!
I downloaded it now but It didn't fixed my problem but actually now I have another problem. So If I keep the code as it is I now get a new error: Cannot compare `void` and `u8
. Hmmm... Interesting!
So the expression is: (c = *s++) != '\0'
. Shouldn't the leftval return the value of "c" which is an i32
like how it would happen in C? Why does it return it as "void"? Or are the rules different in Vox?
I tried to modify the code to the following:
From:
while ((c = *s++) != '\0' && is_digit(c)) {
a = a * 10.0 + (c - '0');
}
To:
c = *s++;
while (c != '\0' && is_digit(c)) {
a = a * 10.0 + (c - '0');
c = *s++;
}
And now, while I don't get this error now, I'm getting the original "illegal hardware instruction" error now. I can't understand what I'm doing wrong really...
Yes, assignments return void
in Vox. Do you get the error during compilation?
Can you reduce the code and post the whole source code that fails?
Yes, assignments return void in Vox
Oh! Why is that? Is there any advantages to that method? Or did you just decided this makes more sense?
Do you get the error during compilation?
Yes.
I will send you the source code in about 2 hours as I'm unable to do that now. Thanks for the support man!
Oh! Why is that? Is there any advantages to that method? Or did you just decided this makes more sense?
Decided to make assignment as expression illegal (it was previously an expression though)
Sorry it took some time but I'm finally home and I have created the snippet. You can see it here. Tell me if you need anything more
Can't access the link
yep, got the crash reproduced, thanks!
You're welcome! If I knew you would be active at that time, I would even upload it earlier
Looks like multiplication of float by constant is triggering, which I haven't implemented yet.
Looks like multiplication of float by constant is triggering, which I haven't implemented yet.
Interesting! Tho still If I take out the expression: c = *s++
, it seems to compile normally for me.
Should be working now
Lol, still not working for me with the new commit. Maybe it's a platform thing idk...
Ok, This is really weird but I played with the code and the behavior doesn't really make sense to me. The same code works in other places and it doesn't work in others. Check the following snippet and focus on the comments:
/* c = *s++; */ // This expression will give use the "illegal hardware instruction" issue if I un-comment it
while (c != '\0' && is_digit(c)) {
a = a * 10.0 + (c - '0');
/* c = *s++; */ // The same happens if I un-comment this out too.
}
if (c == '.') {
c = *s++; // However, the same expression doesn't give the error here
while (c != '\0' && is_digit(c)) {
a = a * 10.0 + (c - '0');
e = e - 1;
c = *s++; // And here too!
}
}
This is part of the function that I uploaded in the gist. So I played it a little bit with it and found this weird behavior out so here is a report sir!
I see the error there, that's another issue
I see the error there, that's another issue
Oh, cool. That was the problem I had that from the beginning. I'm glad I could report it. I'm making a system library so I'll be writing some code and probably I will be able to report some bugs. Vox rocks so far man thanks to your amazing work!!!
there is at least 2 bugs in there
What's the second? You mean separate bugs and not the fact that the expression exists two times right? Also when you saying "bugs" you mean things that have to be fixed/impelemented on Vox on not mistakes I made with my code right?
Any crash or internal error inside of the compiler is a bug. Compiler should report all the invalid code to the user and compile valid code without crashes.
On my machine your source code makes compiler print:
be.emit_mc_amd64(257): ICE: Assertion failure: reg size mismatch 2 != 3
and the stack trace following that
If I modify the source code slightly, then I get a different error:
be.reg_alloc.move_solver(82): ICE: Assertion failure: Second write to r0<c0 s2> detected
Compiler should report all the invalid code to the user and compile valid code without crashes
Yeah, you are right. Creating a multi-platform compiler is hard for sure but still the current state of Vox is amazing!
On my machine your source code....
If I compile with debug with DMD, I will also get similar (but not the same) assertion failure messages. Keep in mind that I'm using the compilation commands as sown in "README.md"
are you not using the CI builds?
No. Is there a difference?
Depends on the flags used to compile. Maybe that is the reason why you did only see Illegal instruction being output. But I'm changing the way internal errors are reported, so it should be more informative and not depend on version switch
But I'm changing the way internal errors are reported, so it should be more informative and not depend on version switch
Thanks! I will use the CI builds in this case. This will also free me of the need to have LDC and Libphobos installed. I may change back in the future especially after I start looking at Vox's code and start contributing. Tell me if you need anything else
Yep! I just used the CI build for Linux (the release one) and the message is exactly the one you posted.
Also the CI build seems slightly faster than the one I made myself with ldc2
You can see the exact commands used to build in CI config here https://github.com/MrSmith33/vox/blob/master/.github/workflows/ci.yml#L56
Thanks man!
I found both issues.
The reg size mismatch 2 != 3
I already fixed.
The other one is in progress.
While I'm fixing it, passing --no-dce
to the compiler should allow you to continue the work.
Man you are a legend and Vox has a future and I hope you love that! Don't rush, I will wait for you to end the job and then I'll try again after the new commit comes out.
God job, I can now confirm that it compiles perfectly!
Btw, I found another error when trying to return a function. Should I create a new issue? Also how would I know of what kind of bugs you are aware and what to post or not? Should you make a list with known bugs and examples and how to produce them so I will know what to do?
*return a value from a function
Should I create a new issue?
Please do.
how would I know of what kind of bugs you are aware and what to post or not?
Some of those are in the todo.txt, some in the tests, some in my head. I guess if there is no github issue, then it should be useful to be reported. If it is new I will fix it. If it is known by me, then it will become known by Vox users too.
Ok, it is decided then. We are posting and you are updating!
I'm trying to create a function to covert a string to a float I'm keep getting the error in the title. I have found out where the error occurs and I will post a snippet of the code.
Code:
So yeah, any ideas why is this happening?
EDIT: This error happens on other places too but I haven't find the exact place yet so let's first fix that one and then I will update for the other places as well.
EDIT: Actually it's only one other place, I fixed the others