datanoise / mongo.cr

Crystal binding for MongoDB C Driver
MIT License
97 stars 35 forks source link

Structs can't have finalizers because they are not tracked by the GC #13

Closed Val closed 7 years ago

Val commented 7 years ago
> crystal spec
Error in line 1: while requiring "./spec/bulk_operation_spec.cr"

in spec/bulk_operation_spec.cr:1: while requiring "../src/mongo"

require "../src/mongo"
^

in src/mongo.cr:2: while requiring "./bson"

require "./bson"
^

in src/bson.cr:3: while requiring "./bson/*"

require "./bson/*"
^

in src/bson/value.cr:14: structs can't have finalizers because they are not tracked by the GC

    def finalize
        ^~~~~~~~

From https://github.com/crystal-lang/crystal/blob/master/CHANGELOG.md#0204-06-01-2017

(breaking change) Defining a finalize method on a struct now gives a compile error

Because of memory leaks, see https://github.com/crystal-lang/crystal/issues/3840

Val commented 7 years ago

Fixed in #15