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

Remove T* and T[N] macro interpolation behavior inside libs #14215

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 19 additions & 0 deletions spec/compiler/parser/to_s_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,25 @@ describe "ASTNode#to_s" do
expect_to_s %(lib Foo\n struct Foo\n a : Void\n b : Void\n end\nend)
expect_to_s %(lib Foo\n union Foo\n a : Int\n b : Int32\n end\nend)
expect_to_s %(lib Foo\n FOO = 0\nend)
expect_to_s <<-CRYSTAL, <<-CRYSTAL
lib Foo
A = Pointer(Void).new(0)
struct B
x : Void*
y : Int[1]
end
fun c(Void*) : Char[2]*
end
CRYSTAL
lib Foo
A = Pointer(Void).new(0)
struct B
x : ::Pointer(Void)
y : ::StaticArray(Int, 1)
end
fun c(::Pointer(Void)) : ::Pointer(::StaticArray(Char, 2))
end
CRYSTAL
expect_to_s %(lib LibC\n fun getch = "get.char"\nend)
expect_to_s %(lib Foo::Bar\nend)
expect_to_s %(enum Foo\n A = 0\n B\nend)
Expand Down
4 changes: 2 additions & 2 deletions spec/compiler/semantic/restrictions_augmenter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ describe "Semantic: restrictions augmenter" do
it "augments typedef" do
before = <<-CRYSTAL
lib LibFoo
type X = Void*
type X = Int32
end
class Foo
@x : LibFoo::X
Expand All @@ -284,7 +284,7 @@ describe "Semantic: restrictions augmenter" do

after = <<-CRYSTAL
lib LibFoo
type X = Void*
type X = Int32
end
class Foo
@x : LibFoo::X
Expand Down
22 changes: 0 additions & 22 deletions src/compiler/crystal/syntax/to_s.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module Crystal
def initialize(@str = IO::Memory.new, @macro_expansion_pragmas = nil, @emit_doc = false)
@indent = 0
@inside_macro = 0
@inside_lib = false
end

def visit_any(node)
Expand Down Expand Up @@ -847,25 +846,6 @@ module Crystal
def visit(node : Generic)
name = node.name

if @inside_lib && (name.is_a?(Path) && name.names.size == 1)
case name.names.first
when "Pointer"
node.type_vars.first.accept self
@str << '*'
return false
when "StaticArray"
if node.type_vars.size == 2
node.type_vars[0].accept self
@str << '['
node.type_vars[1].accept self
@str << ']'
return false
end
else
# Not a special type
end
end

node.name.accept self

printed_arg = false
Expand Down Expand Up @@ -1131,9 +1111,7 @@ module Crystal
@str << "lib "
node.name.accept self
newline
@inside_lib = true
accept_with_indent(node.body)
@inside_lib = false
append_indent
@str << "end"
false
Expand Down