@@ -22,11 +22,14 @@ left-to-right order.)
22
22
assert(text(++i, ++i) == "1415"); // left to right evaluation of arguments
23
23
-------------
24
24
25
- $(P But even though the order of evaluation is well defined, writing code that
26
- depends on it is rarely recommended.
27
- $(B Note that dmd currently does not comply with left to right evaluation of
28
- function arguments and AssignExpression.)
29
- )
25
+ $(IMPLEMENTATION_DEFINED
26
+ $(OL
27
+ $(LI The order of evaluation of the operands of $(GLINK AssignExpression).)
28
+ $(LI The order of evaluation of function arguments.)
29
+ ))
30
+
31
+ $(BEST_PRACTICE Even though the order of evaluation is well defined, writing code that
32
+ depends on it is rarely recommended.)
30
33
31
34
$(H2 $(LEGACY_LNAME2 Expression, expression, Expressions))
32
35
@@ -42,7 +45,7 @@ $(GNAME CommaExpression):
42
45
$(P The left operand of the $(D ,) is evaluated, then the right operand
43
46
is evaluated. The type of the expression is the type of the right
44
47
operand, and the result is the result of the right operand. Using
45
- the result is derecated .
48
+ the result is deprecated .
46
49
)
47
50
48
51
$(H2 $(LNAME2 assign_expressions, Assign Expressions))
@@ -66,13 +69,41 @@ $(GNAME AssignExpression):
66
69
$(GLINK ConditionalExpression) $(D ^^=) $(I AssignExpression)
67
70
)
68
71
69
- $(P The right operand is implicitly converted to the type of the
70
- left operand, and assigned to it. The result type is the type
71
- of the left operand, and the result value is the value of the left
72
- operand after the assignment.
72
+ $(P For all assign expressions, the left operand must be a modifiable
73
+ lvalue. The type of the assign expression is the type of the left
74
+ operand, and the value is the value of the left operand after assignment
75
+ occurs. The resulting expression is a modifiable lvalue.
76
+ )
77
+
78
+ $(UNDEFINED_BEHAVIOR
79
+ $(OL
80
+ $(LI if the lvalue and rvalue have partially overlapping storage)
81
+ $(LI if the lvalue and rvalue's storage overlaps exactly but the types are different)
82
+ ))
83
+
84
+ $(H3 $(LNAME2 simple_assignment_expressions, Simple Assignment Expression))
85
+
86
+ $(P If the operator is $(D =) then it is simple assignment.
87
+ The right operand is implicitly converted to the type of the
88
+ left operand, and assigned to it.)
89
+
90
+ $(P If the left and right operands are of the same struct type, and the struct
91
+ type has a $(GLINK2 struct, Postblit), then the copy operation is
92
+ as described in $(DDSUBLINK spec/struct, struct-postblit, Struct Postblit).
93
+ )
94
+
95
+ $(P If the lvalue is the `.length` property of a dynamic array, the behavior is
96
+ as described in $(DDSUBLINK spec/array, resize, Setting Dynamic Array Length).
73
97
)
74
98
75
- $(P The left operand must be an lvalue.)
99
+ $(P If the lvalue is a static array or a slice, the behavior is as
100
+ described in $(DDSUBLINK spec/array, array-copying, Array Copying) and
101
+ $(DDSUBLINK spec/array, array-setting, Array Setting).
102
+ )
103
+
104
+ $(P If the lvalue is a user-defined property, the behavior is as
105
+ described in $(DDSUBLINK spec/function, property-functions, Property Functions).
106
+ )
76
107
77
108
$(H3 $(LNAME2 assignment_operator_expressions, Assignment Operator Expressions))
78
109
0 commit comments