Skip to content

Instantly share code, notes, and snippets.

@domgetter
Created March 27, 2017 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domgetter/c3d3c65d1bec532bc3917fb8eafb6f28 to your computer and use it in GitHub Desktop.
Save domgetter/c3d3c65d1bec532bc3917fb8eafb6f28 to your computer and use it in GitHub Desktop.
struct Int
macro self_test(name)
def self.{{name}}
"me!"
end
{% debug() %}
end
end
Int.self_test(self_method)
Int.self_method
# The macro debugger prints out
#
# def self.self_method
# "me!"
# end
#
# and then the compiler prints out
#
# Error in src/class_method_macro.cr:11: undefined method 'self_method' for Int:Class
#
# Int.self_method
# ^~~~~~~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment