Compiling SIL with swiftc

Newbie question, is the following supposed to work?

$ ./swiftc -emit-sil -o lookup.sil lookup.swift
$ ./swiftc -parse-sil -o lookup lookup.sil

It fails with a gazillion errors:

lookup.sil:61:25: error: use of undeclared type 'SomeProtocol'
  %23 = metatype $@thin SomeProtocol.Protocol
                        ^~~~~~~~~~~~
lookup.sil:62:3: error: expressions are not allowed at the top level
  %24 = metatype $@thick SomeProtocol.Protocol // user: %25
  ^
lookup.sil:62:17: error: consecutive statements on a line must be separated by ';'
  %24 = metatype $@thick SomeProtocol.Protocol // user: %25
                ^
                ;
...

almost as if it thinks it’s Swift.

— Luke

This should work. I think, though, that if you try to compile multiple files together, it currently parses them all as .swift files, which might explain the failure.

-Joe

···

On Dec 31, 2015, at 2:33 AM, Luke Howard via swift-dev <swift-dev@swift.org> wrote:

Newbie question, is the following supposed to work?

$ ./swiftc -emit-sil -o lookup.sil lookup.swift
$ ./swiftc -parse-sil -o lookup lookup.sil

It fails with a gazillion errors:

lookup.sil:61:25: error: use of undeclared type 'SomeProtocol'
  %23 = metatype $@thin SomeProtocol.Protocol
                        ^~~~~~~~~~~~
lookup.sil:62:3: error: expressions are not allowed at the top level
  %24 = metatype $@thick SomeProtocol.Protocol // user: %25
  ^
lookup.sil:62:17: error: consecutive statements on a line must be separated by ';'
  %24 = metatype $@thick SomeProtocol.Protocol // user: %25
                ^
                ;
...

almost as if it thinks it’s Swift.