[parser/printer] Explicitly specifying "external" linkage is disallowed?

Hey everyone,
I’m trying to figure out if the behavior below is due to historical reasons or if there is something more to it.

The LangRef states (emphasis mine):

Global variables can optionally specify a linkage type.

Global Variables have external linkage by default. So this is legal and has external linkage:

@good_int = global i32 0

However, being explicit about linkage triggers a parse error:

@bad_int = external global i32 0
$ opt test.ll
opt: test.ll:2:32: error: expected top-level entity
@bad_int = external global i32 0

If we make this a declaration and omit the initializer, we can parse successfully:

@good_extern_int = external global i32

But if we now remove the optional linkage, we fail to parse again:

@bad_extern_int = global i32
opt: test.ll:1:1: error: expected value token

The two examples here seem to contradict the “optional” quality of linkage: in the bad_int case, we are forced to omit linkage. In the bad_extern_int we are forced to include linkage. But all four global variables have the exact same linkage. In other words, the “default” value of linkage is not equivalent to spelling out “external” (for parsing purposes). Do we know why this is done this way?

(In case you’re wondering: the logic is inside parseGlobal in lib/AsmParser/LLParser.cpp)

There is an analogous case where internal linkage implies dso_local, but in this case we allow dso_local to be redundantly specified.

You can play around with this here: Compiler Explorer