Skip to content

Commit

Permalink
Fix internal error when calling #is_a? on External nodes (#14918)
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Aug 21, 2024
1 parent 1baf3a7 commit bc569ac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions spec/compiler/macro/macro_methods_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2654,6 +2654,14 @@ module Crystal
end
end

describe External do
it "executes is_a?" do
assert_macro %({{x.is_a?(External)}}), "true", {x: External.new("foo", [] of Arg, Nop.new, "foo")}
assert_macro %({{x.is_a?(Def)}}), "true", {x: External.new("foo", [] of Arg, Nop.new, "foo")}
assert_macro %({{x.is_a?(ASTNode)}}), "true", {x: External.new("foo", [] of Arg, Nop.new, "foo")}
end
end

describe Primitive do
it "executes name" do
assert_macro %({{x.name}}), %(:abc), {x: Primitive.new("abc")}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/crystal/macros/types.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ module Crystal

@macro_types["Arg"] = NonGenericMacroType.new self, "Arg", ast_node
@macro_types["ProcNotation"] = NonGenericMacroType.new self, "ProcNotation", ast_node
@macro_types["Def"] = NonGenericMacroType.new self, "Def", ast_node
@macro_types["Def"] = def_type = NonGenericMacroType.new self, "Def", ast_node
@macro_types["External"] = NonGenericMacroType.new self, "External", def_type
@macro_types["Macro"] = NonGenericMacroType.new self, "Macro", ast_node

@macro_types["UnaryExpression"] = unary_expression = NonGenericMacroType.new self, "UnaryExpression", ast_node
Expand Down Expand Up @@ -102,7 +103,6 @@ module Crystal
# bottom type
@macro_types["NoReturn"] = @macro_no_return = NoReturnMacroType.new self

# unimplemented types (see https://github.com/crystal-lang/crystal/issues/3274#issuecomment-860092436)
@macro_types["Self"] = NonGenericMacroType.new self, "Self", ast_node
@macro_types["Underscore"] = NonGenericMacroType.new self, "Underscore", ast_node
@macro_types["Select"] = NonGenericMacroType.new self, "Select", ast_node
Expand Down

0 comments on commit bc569ac

Please sign in to comment.