Easy syntax and nested entries

This program:

type A = { a : int }
type B = { b : A }

//34567890
let r = {
  b = {      // line 6
    a = 2    // line 7 
  } 
}

Produces this warning twice in mono / fsharpc:

/ Users/debois/git/dcr/foo.fs(7,5): warning FS0058: Possible indentation: this token is in the offside context started in position (6: 7). Try deferring this token further or using standard formatting conventions.

  • Why does this warning occur at all? f # -spec p. 228 makes me think that the "a" next "{" token sets a new line outside the game, in which case there should be no problems?

  • Why does this happen twice?

Thanks,

Søren

Full conclusion:

dcr > fsharpc foo.fs
F# Compiler for F# 3.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License

/Users/debois/git/dcr/foo.fs(7,5): warning FS0058: Possible incorrect indentation: this token is offside of context started at position (6:7). Try indenting this token further or using standard formatting conventions.

/Users/debois/git/dcr/foo.fs(7,5): warning FS0058: Possible incorrect indentation: this token is offside of context started at position (6:7). Try indenting this token further or using standard formatting conventions.
dcr > 
+4
source share
3

, , . F # spec . 229-230, , () ( - ):

(i) (, { begin token.

(ii) , =, () , () try, match, if, let, for, while use.

:

//34567890
let r = {
  b = {      // line 6
    a = 2    // line 7 
  } 
}

b 6 a { offside 3 (i). { 6 = 7 (ii). a 7 5 .

, { 5 offside-line, { 6 - ( ).

+2

type A = { a : int }
type B = { b : A }

//34567890
let r = { b = { a = 2 } }

let r =
    {
       b = { a = 2 } 
    }

. { - .

EDIT: {, , { . .

+2

Spec :

:

  • (, { begin token.

, { spec , {?

NOTE. I agree that the phrase "first token ... token" sounds confusing. Most likely, this should be the "first character ... of the token", since this is applicable to start the \ end case (the off-line line is entered by the column of the "b" character)

begin
 begin
end // possible incorrect indentation: this token is offside of the context started at (2,2)
end

Having two warnings for the same position looks like an error.

0
source

Source: https://habr.com/ru/post/1530724/


All Articles