Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions spec/compiler/semantic/pointer_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ describe "Semantic: pointer" do
end

it "pointer of class raises error" do
assert_error "pointerof(Int32)", "can't take address of Int32"
assert_error "pointerof(Int32)", "can't take address of Int32 because it's a Path. `pointerof` expects a variable or constant."
end

it "pointer of class raises error" do
assert_error "def foo; foo; end; pointerof(foo)", "can't take address of foo because it's a Call. `pointerof` expects a variable or constant."
end

it "pointer of value error" do
assert_error "pointerof(1)", "can't take address of 1"
assert_error "pointerof(1)", "can't take address of 1 because it's a NumberLiteral. `pointerof` expects a variable or constant."
end

it "types pointer value on typedef" do
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/semantic/main_visitor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2589,7 +2589,7 @@ module Crystal
# "undefined local variable or method"
node.exp.accept self

node.exp.raise "can't take address of #{node.exp}"
node.exp.raise "can't take address of #{node.exp} because it's a #{ node.exp.class_desc }. `pointerof` expects a variable or constant."
end

node.bind_to var
Expand Down