count.index*32: unknown count type: 0x0 #2046

Closed
Fodoj opened this Issue May 22, 2015 · 8 comments

Projects

None yet

3 participants

@Fodoj
Contributor
Fodoj commented May 22, 2015

cidr_block = "${concat("10.0.0.", count.index*32, "/2")}" => count.index*32: unknown count type: 0x0

What could be the issue here?

@Fodoj Fodoj changed the title from count.index**32: unknown count type: 0x0 to count.index*32: unknown count type: 0x0 May 22, 2015
@phinze phinze added bug core labels May 22, 2015
@phinze
Member
phinze commented May 22, 2015

Interesting. Looks like a parsing bug. If you space out the math it works!

resource "aws_subnet" "foo" {
  count = "3"
  cidr_block = "${concat("10.0.0.", count.index * 32, "/2")}"
}

Tagged and we'll get this fixed.

@Fodoj
Contributor
Fodoj commented May 22, 2015

Thanks! If you need help fixing it, just point me into right direction and I will prepare PR in next few days

@Fodoj
Contributor
Fodoj commented May 26, 2015

@mitchellh @phinze another bug:

#{128 + count.index * 32} => 4096

I'd like to get it fixed, should I take a look at github.com/hashicorp/terraform/config/lang/ast? Which other components are involved?

@mitchellh
Member

@Fodoj What is the bug there? Our language doesn't do order of ops on its own (all operator precedence is the same). Wrap things in parens to get the order you want.

@Fodoj
Contributor
Fodoj commented Jun 8, 2015

@mitchellh I would normally expect basic math operations to function as they always do. So that kind of operator precedence is totally unexpected and feels unusual at least.

@mitchellh
Member

@Fodoj If you'd like to add precedence that's fine with me, in that case

@Fodoj
Contributor
Fodoj commented Jun 8, 2015

@mitchellh sure. Could you point me into required types in codebase? that's mostly related to ast code, right?

@mitchellh
Member

Precedence should just be the parser code, the YACC syntax (.y) in the config/lang directory.

@mitchellh mitchellh self-assigned this Jun 26, 2015
@mitchellh mitchellh closed this in #2505 Jun 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment