Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringLiteral.camelcase does not handle (lower: true) parameter #8291

Closed
wealth opened this issue Oct 8, 2019 · 5 comments · Fixed by #8429
Closed

StringLiteral.camelcase does not handle (lower: true) parameter #8291

wealth opened this issue Oct 8, 2019 · 5 comments · Fixed by #8429

Comments

@wealth
Copy link

wealth commented Oct 8, 2019

module A
  macro define_method(decl)
    def {{decl.var.camelcase(lower: true)}}
      puts "does not work!"
    end
  end
end

class Z
  include A
  define_method test_column : String
end

Z.new.testColumn

Result:

There was a problem expanding macro 'define_method'

Code in test.cr:11:3

 11 | define_method test_column : String
      ^
Called macro defined in test.cr:2:3

 2 | macro define_method(decl)

Which expanded to:

 > 1 | def TestColumn
                     ^
Error: unexpected token: NEWLINE

Expected: handles lowercase and defines testColumn method

Crystal 0.31.1 [0e2e1d067] (2019-09-30)

LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu
@Blacksmoke16
Copy link
Member

Duplicate of #8292?

@wealth
Copy link
Author

wealth commented Oct 8, 2019

yep, sorry for double post

@wealth wealth changed the title StringLiteral.camelcase does not handle (lower: true parameter StringLiteral.camelcase does not handle (lower: true) parameter Oct 8, 2019
@straight-shoota
Copy link
Member

Reduced:

{{"foo_bar".camelcase(lower: true)}} # => "FooBar"

@Blacksmoke16
Copy link
Member

Blacksmoke16 commented Oct 9, 2019

Do we want to support the same UX? Currently named_args aren't included in the macro method interpret method. It would be doable but might take a bit of work. If not the syntax would just be like {{"foo_bar".camelcase(true)}} which would be quite a bit easier to implement.

@straight-shoota @asterite thoughts?

@asterite
Copy link
Member

asterite commented Oct 9, 2019

It's something nice to have, but I know it's a bit tedious to implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants