@@ -193,27 +193,30 @@ let parseFormatStringInternal (m:range) g (source: string option) fmt bty cty =
193
193
checkNoZeroFlag c
194
194
checkNoNumericPrefix c
195
195
196
- let collectSpecifierLocation relLine relCol =
196
+ let collectSpecifierLocation relLine relCol numStdArgs =
197
+ let numArgsForSpecifier =
198
+ numStdArgs + ( if widthArg then 1 else 0 ) + ( if precisionArg then 1 else 0 )
197
199
match relLine with
198
200
| 0 ->
199
201
specifierLocations.Add(
200
- Range.mkFileIndexRange m.FileIndex
202
+ ( Range.mkFileIndexRange m.FileIndex
201
203
( Range.mkPos m.StartLine ( startCol + offset))
202
- ( Range.mkPos m.StartLine ( relCol + offset)))
204
+ ( Range.mkPos m.StartLine ( relCol + offset))), numArgsForSpecifier )
203
205
| _ ->
204
206
specifierLocations.Add(
205
- Range.mkFileIndexRange m.FileIndex
207
+ ( Range.mkFileIndexRange m.FileIndex
206
208
( Range.mkPos ( m.StartLine + relLine) startCol)
207
- ( Range.mkPos ( m.StartLine + relLine) relCol))
209
+ ( Range.mkPos ( m.StartLine + relLine) relCol)), numArgsForSpecifier )
208
210
209
211
let ch = fmt.[ i]
210
212
match ch with
211
- | '%' ->
213
+ | '%' ->
214
+ collectSpecifierLocation relLine relCol 0
212
215
parseLoop acc ( i+ 1 , relLine, relCol+ 1 )
213
216
214
217
| ( 'd' | 'i' | 'o' | 'u' | 'x' | 'X' ) ->
215
218
if info.precision then failwithf " %s " <| FSComp.SR.forFormatDoesntSupportPrecision( ch.ToString())
216
- collectSpecifierLocation relLine relCol
219
+ collectSpecifierLocation relLine relCol 1
217
220
parseLoop (( posi, mkFlexibleIntFormatTypar g m) :: acc) ( i+ 1 , relLine, relCol+ 1 )
218
221
219
222
| ( 'l' | 'L' ) ->
@@ -228,59 +231,59 @@ let parseFormatStringInternal (m:range) g (source: string option) fmt bty cty =
228
231
failwithf " %s " <| FSComp.SR.forLIsUnnecessary()
229
232
match fmt.[ i] with
230
233
| ( 'd' | 'i' | 'o' | 'u' | 'x' | 'X' ) ->
231
- collectSpecifierLocation relLine relCol
234
+ collectSpecifierLocation relLine relCol 1
232
235
parseLoop (( posi, mkFlexibleIntFormatTypar g m) :: acc) ( i+ 1 , relLine, relCol+ 1 )
233
236
| _ -> failwithf " %s " <| FSComp.SR.forBadFormatSpecifier()
234
237
235
238
| ( 'h' | 'H' ) ->
236
239
failwithf " %s " <| FSComp.SR.forHIsUnnecessary()
237
240
238
241
| 'M' ->
239
- collectSpecifierLocation relLine relCol
242
+ collectSpecifierLocation relLine relCol 1
240
243
parseLoop (( posi, g.decimal_ ty) :: acc) ( i+ 1 , relLine, relCol+ 1 )
241
244
242
245
| ( 'f' | 'F' | 'e' | 'E' | 'g' | 'G' ) ->
243
- collectSpecifierLocation relLine relCol
246
+ collectSpecifierLocation relLine relCol 1
244
247
parseLoop (( posi, mkFlexibleFloatFormatTypar g m) :: acc) ( i+ 1 , relLine, relCol+ 1 )
245
248
246
249
| 'b' ->
247
250
checkOtherFlags ch
248
- collectSpecifierLocation relLine relCol
251
+ collectSpecifierLocation relLine relCol 1
249
252
parseLoop (( posi, g.bool_ ty) :: acc) ( i+ 1 , relLine, relCol+ 1 )
250
253
251
254
| 'c' ->
252
255
checkOtherFlags ch
253
- collectSpecifierLocation relLine relCol
256
+ collectSpecifierLocation relLine relCol 1
254
257
parseLoop (( posi, g.char_ ty) :: acc) ( i+ 1 , relLine, relCol+ 1 )
255
258
256
259
| 's' ->
257
260
checkOtherFlags ch
258
- collectSpecifierLocation relLine relCol
261
+ collectSpecifierLocation relLine relCol 1
259
262
parseLoop (( posi, g.string_ ty) :: acc) ( i+ 1 , relLine, relCol+ 1 )
260
263
261
264
| 'O' ->
262
265
checkOtherFlags ch
263
- collectSpecifierLocation relLine relCol
266
+ collectSpecifierLocation relLine relCol 1
264
267
parseLoop (( posi, NewInferenceType ()) :: acc) ( i+ 1 , relLine, relCol+ 1 )
265
268
266
269
| 'A' ->
267
270
match info.numPrefixIfPos with
268
271
| None // %A has BindingFlags=Public, %+A has BindingFlags=Public | NonPublic
269
272
| Some '+' ->
270
- collectSpecifierLocation relLine relCol
273
+ collectSpecifierLocation relLine relCol 1
271
274
parseLoop (( posi, NewInferenceType ()) :: acc) ( i+ 1 , relLine, relCol+ 1 )
272
275
| Some _ -> failwithf " %s " <| FSComp.SR.forDoesNotSupportPrefixFlag( ch.ToString(), ( Option.get info.numPrefixIfPos) .ToString())
273
276
274
277
| 'a' ->
275
278
checkOtherFlags ch
276
279
let xty = NewInferenceType ()
277
280
let fty = bty - -> ( xty - -> cty)
278
- collectSpecifierLocation relLine relCol
281
+ collectSpecifierLocation relLine relCol 1
279
282
parseLoop (( Option.map ((+) 1 ) posi, xty) :: ( posi, fty) :: acc) ( i+ 1 , relLine, relCol+ 1 )
280
283
281
284
| 't' ->
282
285
checkOtherFlags ch
283
- collectSpecifierLocation relLine relCol
286
+ collectSpecifierLocation relLine relCol 1
284
287
parseLoop (( posi, bty - -> cty) :: acc) ( i+ 1 , relLine, relCol+ 1 )
285
288
286
289
| c -> failwithf " %s " <| FSComp.SR.forBadFormatSpecifierGeneral( String.make 1 c)
0 commit comments