My Nim Development Weekly Report (3/12)
Tags: nim, opensource, contributorswanted
Published: 2023-03-13 03:28:03

## Progress

### chores

[closes #16654; add a test case](https://github.com/nim-lang/Nim/pull/21478).

[closes #20704; add a test case](https://github.com/nim-lang/Nim/pull/21480).

[closes #6231; add a test case](https://github.com/nim-lang/Nim/pull/21485).

[closes #8295; add a test case](https://github.com/nim-lang/Nim/pull/21486).

[fixes sinkinference documentation, which has been disabled](https://github.com/nim-lang/Nim/pull/21470).

### following up PRs

[fixes quoted variables with typedesc types](https://github.com/nim-lang/Nim/pull/21493).

[fixes explicit globals in macros](https://github.com/nim-lang/Nim/pull/21502).


### fixes @[] and {} type inference as returns in generics

[fixes #21377; fixes @[] and {} type inference as returns in generics](https://github.com/nim-lang/Nim/pull/21475).

```nim
  proc b[T](v: T): seq[int] =
    let x = 0
    @[]

  doAssert b(0) == @[]
```

The type of `@[]` is incomplete, which is of `seq[empty]` type. By means of the return type of the generics, we could infer its type. Using top down type inference, we pass the expected type, namely `seq[int]`, to the return expression. Finally, the return type is passed to the magic `mArrToSeq`, where we replace the incomplete type with `seq[int]`.

### Initialize all the missing fields when discriminator is assigned

[fixes #21023; Segfault when mixing seqs, orc, variants and futures](https://github.com/nim-lang/Nim/pull/21497).

```nim
type
  Result = object
    case o: bool
    of false:
      e: int
    of true:
      v: float
```

`var x = Result(o: true)` is now equal to `var x = Result(o: true, v: 0.0)`. The `v` field is initialized to `0.0` so that it won't cause problems for ARC/ORC.

### don't transform yields in the var section when introducing new local vars

[fixes #21306; fixes #20485; don't transform yields in the var section when introducing new local vars](https://github.com/nim-lang/Nim/pull/21489).

### fixes ambiguous calls compiles when module name are equal

[fixes #21496; fixes ambiguous calls compiles when module name are equal](https://github.com/nim-lang/Nim/pull/21500).

```
- a
   - def.nim
- b
   - def.nim
- project.nimble
```

The `a/def` and `b/def` shares the same owner, namely `project` which is the name of the nimble file. We cannot distinguish them by their owners.

```nim
if sym.kind == skModule and conflict.kind == skModule and sym.owner == conflict.owner:
```

Instead, we need to use `sym.position` which stands for an unique index corresponding to the module's fileIdx for symbols with a `skModule` kind.

```nim
if sym.kind == skModule and conflict.kind == skModule and sym.position == conflict.position:
```

## Weekly collection

https://forum.nim-lang.org/t/9908 (2/19)

https://forum.nim-lang.org/t/9940 (2/26)

https://forum.nim-lang.org/t/9970 (3/5)

## Participating in contributions

Following [The Roadmap 2023 for community building ](https://github.com/nim-lang/RFCs/issues/513), you could join us in [the matrix space](https://matrix.to/#/!ZmWXggMgfkKpcLbQkB:matrix.org?via=matrix.org) where we discuss how to build a community. We appreciate doable suggestions and helps, such as improving the workflow, implementing the roadmap, suggesting doable tasks, reviewing code from contributors. United we stand. We shall work together to make the community thrive.

## Sponsorship

Many thanks to Yepoleb, lenis0012, pietroppeter, Clonkk, mode80, Phil, CxPlanner, shirleyquirk, elcritch, geotre, thinkwelltwd, xrfez, enthus1ast, piertoni, Dnanilem for [sponsoring me on GitHub](https://github.com/sponsors/planety).