File tree Expand file tree Collapse file tree 6 files changed +21
-5
lines changed
java/org/truffleruby/core/kernel Expand file tree Collapse file tree 6 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -2041,4 +2041,20 @@ protected Object warn(
2041
2041
2042
2042
}
2043
2043
2044
+ @ Primitive (name = "warn_block_supersedes_default_value_argument" )
2045
+ public abstract static class WarnBlockSupersedesDefaultValueArgumentNode extends PrimitiveNode {
2046
+ @ Specialization
2047
+ protected Object warn (
2048
+ @ Cached ("new()" ) WarnNode warnNode ) {
2049
+ if (warnNode .shouldWarn ()) {
2050
+ warnNode .warningMessage (
2051
+ getContext ().getCallStack ().getTopMostUserSourceSection (),
2052
+ "block supersedes default value argument" );
2053
+ }
2054
+
2055
+ return Nil .INSTANCE ;
2056
+ }
2057
+
2058
+ }
2059
+
2044
2060
}
Original file line number Diff line number Diff line change @@ -407,7 +407,7 @@ def fetch(idx, default=undefined)
407
407
408
408
if idx < 0 or idx >= size
409
409
if block_given?
410
- warn 'block supersedes default value argument' , uplevel : 1 unless Primitive . undefined? ( default )
410
+ Primitive . warn_block_supersedes_default_value_argument unless Primitive . undefined? ( default )
411
411
412
412
return yield ( orig )
413
413
end
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ def include?(key)
143
143
144
144
def fetch ( key , absent = undefined )
145
145
if block_given? and !Primitive . undefined? ( absent )
146
- warn 'block supersedes default value argument' , uplevel : 1
146
+ Primitive . warn_block_supersedes_default_value_argument
147
147
end
148
148
149
149
if value = lookup ( key )
Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ def fetch(key, default=undefined)
231
231
end
232
232
233
233
if block_given?
234
- warn 'block supersedes default value argument' , uplevel : 1 unless Primitive . undefined? ( default )
234
+ Primitive . warn_block_supersedes_default_value_argument unless Primitive . undefined? ( default )
235
235
236
236
return yield ( key )
237
237
end
Original file line number Diff line number Diff line change @@ -223,7 +223,7 @@ def report_on_exception=(val)
223
223
end
224
224
225
225
def fetch ( name , default = undefined )
226
- warn 'block supersedes default value argument' if !Primitive . undefined? ( default ) && block_given?
226
+ Primitive . warn_block_supersedes_default_value_argument if !Primitive . undefined? ( default ) && block_given?
227
227
228
228
key = convert_to_local_name ( name )
229
229
locals = Primitive . thread_get_fiber_locals self
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ def fetch(key, default = undefined)
156
156
end
157
157
158
158
if block_given?
159
- warn 'block supersedes default value argument' , uplevel : 1 unless Primitive . undefined? ( default )
159
+ Primitive . warn_block_supersedes_default_value_argument unless Primitive . undefined? ( default )
160
160
161
161
return yield ( key )
162
162
end
You can’t perform that action at this time.
0 commit comments