# Sema: support enough to check main calling convention via \`@typeInfo\` · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/47531b7d9389c45af3e46b623235792f14a40ff2)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 47531b7d9389c45af3e46b623235792f14a40ff2

Requested commit: 47531b7d9389c45af3e46b623235792f14a40ff2

Commit: 47531b7d9389c45af3e46b623235792f14a40ff2

Tree: 9412cb8c20a690381e58d607e6348028e19ab3d2

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
Sema: support enough to check main calling convention via `@typeInfo`

After this commit, `pub export fn main() c_int { ... }` will be
correctly detected as the intended entry point, and therefore start code
will not try to export its own conflicting `main` function.

 * Implement basic union support
   - lots of stuff is still TODO, including runtime field access
   - also TODO: resolving the union tag type
   - comptime field access is implemented
 * DRY up some code by using the `Zir.DeclIterator` for skipping over
   decls in structs and unions.
 * Start to clean up Sema with regards to calling `.value()` to find out
   a const value. Instead, Sema code should call one of these two:
   - `resolvePossiblyUndefinedValue` (followed by logic dealing with
     undefined values)
   - `resolveDefinedValue` (a compile error will be emitted if the value
     is undefined)
 * An exported function with an unspecified calling convention gets the
   C calling convention.
 * Implement comptime field access for structs.
 * Add another implementation of "type has one possible value" in Sema.
   This is a bit unfortunate since the logic is duplicated, but the one
   in Type asserts that the types are resolved already, and is
   appropriate to call from codegen, while the one in Sema performs
   type resolution if necessary, reporting any compile errors that occur
   in the process.

```

## Parents

- [a7221ef4e902e63e72524559a067afcf6c1dfd17](https://git.cafe/gitcafe/zig/commit/a7221ef4e902e63e72524559a067afcf6c1dfd17?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/47531b7d9389c45af3e46b623235792f14a40ff2?format=markdown)
