It seems that print(-1.f()) is being parsed as print(-(1.f())), not print((-1).f()).
Personally, I’d expect it to parse as print((-1).f()) as well, especially given that -0x80 as Int8 is allowed but 0x80 as Int8 is not allowed. Perhaps there should be a warning about this behavior?
Oh, I was so focused on the abs(-1) part thanks for clearing that up! So it's not a bug after all!
I agree that the minus sign should have higher precedence as part of a literal, but perhaps that would be counterintuitive with variables and function calls.
I think there is definitely a bug in the syntax highlighter here.
If you write print(-1.f()) in Swift Playgrounds for iPad, then you’ll see that -1 is highlighted as a numeric literal, despite the fact that the - is not part of the numeric literal. The - should instead be highlighted as a function.
This even happens if you use parentheses in the expression, resulting in one parenthesis having a different color than the rest:
I haven’t tested this on my Mac yet, but it seems likely that Xcode has this bug too. Visual Studio Code’s syntax highlighter also has this bug when parentheses aren’t used, but behaves correctly when parentheses are used.