# Issue with @parameter

**URL:** <https://forum.modular.com/t/issue-with-parameter/2666>\
**Category:** Mojo\
**Created:** [February 1, 2026, 10:34am UTC](https://forum.modular.com/t/issue-with-parameter/2666 "2026-02-01T10:34:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![notooth](https://avatars.discourse-cdn.com/v4/letter/n/ce73a5/32.png) [@notooth](https://forum.modular.com/u/notooth)\
**Post date:** [February 1, 2026, 10:34am UTC](https://forum.modular.com/t/issue-with-parameter/2666/1 "2026-02-01T10:34:19Z")

</div>

Please help me fix this code:

```auto
@parameter
if False:
    comptime s = "Hello"
else:
    comptime s = "World"

fn main():
    print(s)

```

Error:

```auto
error: use of unknown declaration 's'
    print(s)
          ^

```

---

<div class="post-metadata">

**Author:** ![monte](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@monte](https://forum.modular.com/u/monte)\
**Post date:** [February 1, 2026, 1:48pm UTC](https://forum.modular.com/t/issue-with-parameter/2666/2 "2026-02-01T13:48:50Z")

</div>

> [@notooth](#):
>
> ```auto
> @parameter
> if False:
> comptime s = "Hello"
> else:
> comptime s = "World"
> 
> fn main():
> print(s)
> 
> ```

Interestingly, the following works on current nightly:

```auto
comptime s = "Hello" if False else "World"

fn main():
    print(s)

```

```auto
ASM generation compiler returned: 0
Execution build compiler returned: 0
Program returned: 0
World

```

---

<div class="post-metadata">

**Author:** ![sora](https://avatars.discourse-cdn.com/v4/letter/s/ad7895/32.png) [@sora](https://forum.modular.com/u/sora)\
**Post date:** [February 1, 2026, 7:16pm UTC](https://forum.modular.com/t/issue-with-parameter/2666/3 "2026-02-01T19:16:59Z")

</div>

Yea, that’s roughly control flow vs just a expression.

---

<div class="post-metadata">

**Author:** ![clattner](https://sea1.discourse-cdn.com/flex001/user_avatar/forum.modular.com/clattner/32/201_2.png) [@clattner](https://forum.modular.com/u/clattner)\
**Post date:** [February 1, 2026, 7:32pm UTC](https://forum.modular.com/t/issue-with-parameter/2666/4 "2026-02-01T19:32:40Z")

</div>

The “if else” approach is the right approach. `@parameter if` isn’t like a `#ifdef` in that removed by a preprocessor. It has proper scoping.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex001/uploads/modular/original/1X/2751e0fbdc595a99718b216730957e9db4448cfd.jpeg) [@system](https://forum.modular.com/u/system)\
**Post date:** [February 8, 2026, 7:33pm UTC](https://forum.modular.com/t/issue-with-parameter/2666/5 "2026-02-08T19:33:37Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
