# Conditional code shadows \_\_LINE\_\_

**URL:** <https://forum.crystal-lang.org/t/conditional-code-shadows-line/6778>\
**Category:** Help & Support\
**Created:** [April 22, 2024, 12:16pm UTC](https://forum.crystal-lang.org/t/conditional-code-shadows-line/6778 "2024-04-22T12:16:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hutou](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hutou/32/1337_2.png) [@hutou](https://forum.crystal-lang.org/u/hutou)\
**Post date:** [April 22, 2024, 12:16pm UTC](https://forum.crystal-lang.org/t/conditional-code-shadows-line/6778/1 "2024-04-22T12:16:51Z")

</div>

Given the following code:

```auto
{% if flag?(:DBG) %}
  def foo(x, linenum = 0)
    puts "x=#{x} : linenum=#{linenum}"
  end

  def bar
    foo("abc", linenum: __LINE__ )
    foo("def", linenum: __LINE__ )
    foo("ghi", linenum: __LINE__ )
  end
{% else %}
  def foo(x)
    puts "x=#{x}"
  end

  def bar
    foo("abc")
    foo("def")
    foo("ghi")
  end
{% end %}

bar

```

Running `crystal run foobar.cr -D DBG` outputs:

```auto
x=abc : linenum=1
x=def : linenum=1
x=ghi : linenum=1  

```

Is this expected behaviour ?

I would have expected :

```auto
x=abc : linenum=7
x=def : linenum=8
x=ghi : linenum=9  

```

---

<div class="post-metadata">

**Author:** ![HertzDevil](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hertzdevil/32/1023_2.png) [@HertzDevil](https://forum.crystal-lang.org/u/HertzDevil)\
**Post date:** [April 22, 2024, 12:28pm UTC](https://forum.crystal-lang.org/t/conditional-code-shadows-line/6778/2 "2024-04-22T12:28:31Z")

</div>

Yes, `{{ __LINE__ }}` inside the macro should work the way you want

---

<div class="post-metadata">

**Author:** ![hutou](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/hutou/32/1337_2.png) [@hutou](https://forum.crystal-lang.org/u/hutou)\
**Post date:** [April 22, 2024, 12:41pm UTC](https://forum.crystal-lang.org/t/conditional-code-shadows-line/6778/3 "2024-04-22T12:41:55Z")

</div>

Thanks @HertzDevil  
Of course, it’s obvious now!
