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

table construction: internal error, and lack of guard #1758

Open
shriram opened this issue Sep 9, 2024 · 2 comments
Open

table construction: internal error, and lack of guard #1758

shriram opened this issue Sep 9, 2024 · 2 comments
Assignees

Comments

@shriram
Copy link
Member

shriram commented Sep 9, 2024

This program works fine:

include tables

[table-from-rows:
    [raw-row: {"A"; 5}, {"B"; 7}, {"C"; 8}],
    [raw-row: {"A"; 1}, {"B"; 2}, {"C"; 3}]]

but a natural bug is to produce this instead:

[table-from-rows:
  [list:
    [raw-row: {"A"; 5}, {"B"; 7}, {"C"; 8}],
    [raw-row: {"A"; 1}, {"B"; 2}, {"C"; 3}]]]

(e.g., through map).

Not only does this not produce a graceful error, it says to report a bug:

image

@blerner
Copy link
Member

blerner commented Sep 9, 2024

Ugh there are actually missing annotations here:

  1. https://github.com/brownplt/pyret-lang/blob/horizon/src/arr/trove/tables.arr#L103 calls https://github.com/brownplt/pyret-lang/blob/horizon/src/arr/trove/tables.arr#L91, which does not annotate its argument as a RawArray.
  2. Even if it did, that would be a shallow check, so it would need to be RawArray%(check-that-they-really-are-rows)

I'm not at my coding computer right now; @ds26gte can you take this one? Add a type definition and/or predicate in table.js to check RawArrayOfRows, akin to how the image library does a list of colors (https://github.com/brownplt/code.pyret.org/blob/horizon/src/web/js/trove/internal-image-typed.js#L314), and use it to annotate table-from-raw-array.

@ds26gte
Copy link
Contributor

ds26gte commented Sep 9, 2024

Please review that PR #1759 does what's needed.

ds26gte added a commit to ds26gte/pyret-lang that referenced this issue Sep 10, 2024
ds26gte added a commit to ds26gte/pyret-lang that referenced this issue Sep 10, 2024
- a (second) test that checks all values are raw-rows
- one that checks that the raw-rows contain only tuples
ds26gte added a commit to ds26gte/pyret-lang that referenced this issue Dec 6, 2024
- tables.arr: use annotation RawArrayOfRows for better err msgs brownplt#1758
- table.js: uses JSModule, so as to include type RawArrayOfRows
- post-load-hooks.js, reactors.js: modify field access to table.js
- test-tables.arr: update table-from-rows tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants