Conversation
src/ddmd/expression.d
Outdated
| semanticTypeInfo(sc, t1.nextOf()); | ||
|
|
||
| // Lowering to template call | ||
| Identifier id = Identifier.idPool("__cmp"); |
There was a problem hiding this comment.
call it __cmp or something like that since that is the id it represents.
Also maybe it would be useful to add it to idgen.d
Such that you don't have to call idPool every time, which is not a cheap call.
|
OK, so this should work with the latest update to dlang/druntime#1787, could you please patch that and make sure it works? |
|
I merged dlang/druntime#1787 so let's see what the autotester says. |
andralex
left a comment
There was a problem hiding this comment.
LGTM of course modulo it passing tests. @WalterBright ?
src/ddmd/expression.d
Outdated
| { | ||
| semanticTypeInfo(sc, t1.nextOf()); | ||
|
|
||
| // Lowering to template call |
There was a problem hiding this comment.
Would be nice to document what the template call is (it's not obvious from the sequence of AST node creations and links).
<ihaveadream>
Would be great to have the ability to create an AST fragment from a string source, a la:
auto node = makeExpression!"__cmp($1, $2)"(e1, e2);whereby makeExpression parses the string during compilation (of dmd), creates the appropriate AST fragment, places the two expressions in lieu of $1 and $2, and returns the created expression node.
I assume a large hunk of compiler code would be drastically simplified.
</ihaveadream>
There was a problem hiding this comment.
Yep, just replace the comment by // Lower to .object.__cmp(e1, e2) or something like that.
src/ddmd/expression.d
Outdated
| if ((t1.ty == Tarray || t1.ty == Tsarray) && (t2.ty == Tarray || t2.ty == Tsarray)) | ||
| { | ||
| semanticTypeInfo(sc, t1.nextOf()); | ||
|
|
There was a problem hiding this comment.
Don't need TypeInfo anymore, so don't need the above line.
src/ddmd/expression.d
Outdated
| arguments.push(e2); | ||
|
|
||
| al = new CallExp(loc, al, arguments); | ||
| al = al.semantic(sc); |
There was a problem hiding this comment.
only need one call to semantic() at the end.
src/ddmd/expression.d
Outdated
| al = new CallExp(loc, al, arguments); | ||
| al = al.semantic(sc); | ||
|
|
||
| al = new CmpExp(op, loc, al, new IntegerExp(loc, 0, Type.tint32)); |
There was a problem hiding this comment.
new IntegerExp(0) is sufficient.
|
@somzzz please take a look at the autotester (e.g. https://auto-tester.puremagic.com/show-run.ghtml?projectid=1&runid=2431115&isPull=true), looks like a clerical issue: All: I'm also seeing a bazillion of these: ddmd/backend/ptrntab.c:5773: warning: dereferencing type-punned pointer will break strict-aliasing rules. |
|
@andralex I don't see the trailing whitespace on that line. Also, it's not clear what the problem with However it seems like there are issues with |
src/ddmd/expression.d
Outdated
|
|
||
| al = new CallExp(loc, al, arguments); | ||
| al = new CmpExp(op, loc, al, new IntegerExp(0)); | ||
| al = al.semantic(sc); |
There was a problem hiding this comment.
If I comment this line, test fail_compilation/ice11755.d should pass as the output is the one desired. However, druntime tests will fail.
Calling semantic generates new output which doesn't match the one expected. What is the best approach in this case?
There was a problem hiding this comment.
If I return al at the end of this code block, I get the following compilation error output for that test:
fail_comp.d(4): Error: floating point operator '!<>=' always returns false for non-floating comparisons
fail_comp.d(5): Error: use '==' for non-floating comparisons rather than floating point operator '!<>'
fail_comp.d(6): Error: use '!=' for non-floating comparisons rather than floating point operator '<>'
fail_comp.d(7): Error: floating point operator '<>=' always returns true for non-floating comparisons
fail_comp.d(8): Error: use '<=' for non-floating comparisons rather than floating point operator '!>'
fail_comp.d(9): Error: use '<' for non-floating comparisons rather than floating point operator '!>='
fail_comp.d(10): Error: use '>=' for non-floating comparisons rather than floating point operator '!<'
fail_comp.d(11): Error: use '>' for non-floating comparisons rather than floating point operator '!<='
fail_comp.d(12): Error: floating point operator '<>=' always returns true for non-floating comparisons
fail_comp.d(13): Error: floating point operator '!<>=' always returns false for non-floating comparisons
There is no more duplication, but the output is not precisely the same as the one expected, which is
fail_compilation/ice11755.d(20): Error: '!<>=' is not defined for array comparisons
fail_compilation/ice11755.d(21): Error: use '==' for non-floating comparisons rather than floating point operator '!<>'
fail_compilation/ice11755.d(22): Error: use '!=' for non-floating comparisons rather than floating point operator '<>'
fail_compilation/ice11755.d(23): Error: '<>=' is not defined for array comparisons
fail_compilation/ice11755.d(24): Error: use '<=' for non-floating comparisons rather than floating point operator '!>'
fail_compilation/ice11755.d(25): Error: use '<' for non-floating comparisons rather than floating point operator '!>='
fail_compilation/ice11755.d(26): Error: use '>=' for non-floating comparisons rather than floating point operator '!<'
fail_compilation/ice11755.d(27): Error: use '>' for non-floating comparisons rather than floating point operator '!<='
fail_compilation/ice11755.d(28): Error: floating point operator '<>=' always returns true for non-floating comparisons
fail_compilation/ice11755.d(29): Error: floating point operator '!<>=' always returns false for non-floating comparisons
There was a problem hiding this comment.
It seems like a specific error message Error: '!<>=' is not defined for array comparisons is replaced with Error: floating point operator '!<>=' always returns false for non-floating comparisons
There was a problem hiding this comment.
Calling semantic at the very end of the function was the answer to all problems.
|
@somzzz |
|
@UplinkCoder Neat! I checked it out. Luckily there was no whitespace to be found in |
|
Whoa, things are passing. Neat! |
|
I thought we agreed to check Martin's project tester before merging this to master... I don't see it in the CI status listing. @MartinNowak ? |
|
Yah, I was surprised too that setting the auto-merge label didn't wait for the CI to finish. |
| if (arrayLowering) | ||
| { | ||
| arrayLowering = arrayLowering.semantic(sc); | ||
| return arrayLowering; |
There was a problem hiding this comment.
Looks a bit pedestrian, nothing wrong with return arrayLowering.semantic(sc);
There was a problem hiding this comment.
This style in dmd comes from Walter wanting to be able to trivially insert prints before the return, and I tend to agree.
|
@andralex The auto-merge label currently doesn't check the project tester. It only looks at the auto-tester, the doc builder, Circle, and CodeCov. |
|
@MartinNowak What's the status of the project tester, can we see whether this broke anything? |
This is the
dmdcode which calls the new__cmptemplate from druntime,.dlang/druntime#1781