You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When defining a type using light syntax (it doesn't matter what kind of type: class, interface, union, record), it is possible to define what appears to be a nested module (at the same indentation level as the rest of the contents of the type), but what actually results in a module defined in the same scope as the type.
typeIFace=abstractF :int->intmoduleM =letf()=()typeC()=member_.F()=3moduleM2 =letf()=()typeU=| A
| B
moduleM3 =letf()=()typeR={ A :int }moduleM4 =letf()=()// Etc.// All modules M, M2, M3, M4 are in scope here.
typeIFace=interfaceabstractF :int->intmoduleM =// FS0010: Unexpected keyword 'module' in type definition. Expected 'end' or other token.letf()= f ()end// Etc.
Expected behavior
A module nested inside of a type shouldn't compile, or some kind of indentation warning should be given.
Actual behavior
The module is compiled in the same scope as the type.
Known workarounds
Don't confusingly misindent your module definition.
The text was updated successfully, but these errors were encountered:
For this I think it would make sense to emit a warning. I suppose this is considered by design but it's reasonable to warn since the code is kind of wonky.
@cartermp@dsyme Would you accept a language suggestion producing errors for these cases? I think making the light syntax work properly (or just in more predictable ways) in more cases is really important.
@cartermp@dsyme Would you accept a language suggestion producing errors for these cases? I think making the light syntax work properly (or just in more expected ways) in more cases is really important.
Definitely would accept a PR that produces a warning for this case
When defining a type using light syntax (it doesn't matter what kind of type: class, interface, union, record), it is possible to define what appears to be a nested module (at the same indentation level as the rest of the contents of the type), but what actually results in a module defined in the same scope as the type.
https://sharplab.io/#v2:DYLgZgzgPgLgngBwKYAICSAxAhgY1QXgFgAoFMlLAIwhgCdcYUMUQUBLAO0YFoA+driXIoAtgHsAJgFdgqALIoipYeVmMwKABQBKRVu0kS8ZCgDC+xUPIikIyklooA+gDpmOvQGYrZcdNkocgBMlsoqKGooGh74+obExqgAqqHCUCgAgj4o6QBC2X4y8p6p4RFI6haxOvGJKABKpWQA3pksAowAvgWSRYEALE0qkdG61QbEQA===
Using verbose syntax disallows this, as expected.
https://sharplab.io/#v2:DYLgZgzgPgLgngBwKYAICSAxAhgY1QXgFgAoFMlASwDsYkAnMXJE81lLAIwhjtxhQwoQlGigC0APhEwWbMgFsA9gBMArsFQBZFPhQB6PQIDKABhMBGE8ICqVJAA9kOWspQBrJHADuiuq4DkSmoa/iIo8Mgoykhg1BQwFIpUAHQoAKKOSM5IAUhUyqG+KIowABb04YoeKbJyrBr8YCgAFACUOihNbbUoecpAA
Expected behavior
A module nested inside of a type shouldn't compile, or some kind of indentation warning should be given.
Actual behavior
The module is compiled in the same scope as the type.
Known workarounds
Don't confusingly misindent your module definition.
The text was updated successfully, but these errors were encountered: