[generics-rep] Trivial genericShow blows up the call stack

Đang mở
#245 7 bình luận 6 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Lĩnh vực
backend

Hướng nghiên cứu

Start by reading the genericShow and generic representation code referenced in the stack trace, then reproduce the failure with the VVis and Frame definitions in the issue. Trace why deriving Show for the nested generic types recurses until the stack overflows; done means identifying the cause and confirming a fix prevents the overflow for this example.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

type: documentation

I have the following code in my library:

data VVis a
  = Fill a (Frame a)
  | ...

derive instance genericVVis :: Generic (VVis a) _
instance showVVis :: Show a => Show (VVis a) where
  show = genericShow

data Frame a = Frame
  { frameMax :: a
  , frameMin :: a
  }

derive instance genericFrame :: Generic (Frame a) _
instance showFrame :: Show a => Show (Frame a) where
  show = genericShow

If I now load my code in a REPL and create the following trivial value:

> Fill 2.0 (Frame {frameMax: 1.0, frameMin: 0.0})
return new Data_Show.Show(Data_Generic_Rep_Show.genericShow(genericVVis)(Data_Generic_Rep_Show.genericShowSum(Data_Generic_Rep_Show.genericShowConstructor(Data_Generic_Rep_Show.genericShowArgsProduct(Data_Generic_Rep_Show.genericShowArgsArgument(dictShow))(Data_Generic_Rep_Show.genericShowArgsArgument(showFrame(dictShow))))(new Data_Symbol.IsSymbol(function () {
                                                                             ^

RangeError: Maximum call stack size exceeded
...

This is a very small value, so I don't understand why this is blowing up the call stack. Could somebody help me understand please?

Ngôn ngữ chính
PureScript
Star
168
Fork
90
Merge trung bình
3 ngày 1 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của purescript/purescript-prelude

Tất cả issue của purescript/purescript-prelude

Issue tương tự

Thêm issue về Backend & API Design

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.