Commit graph

1466 commits

Author SHA1 Message Date
Ruud van Asseldonk
95a4d7728c Try to improve Collection docs
Still not really happy with this, but it's better I think.
2025-03-27 22:40:06 +01:00
Ruud van Asseldonk
840aa1b5aa Add some docs for the Collection type
I am not really happy with this, because the type is not really
something that end-users should use (although they can), it's more for
the typechecker internally. How to explain this nicely?
2025-03-15 22:22:49 +01:00
Ruud van Asseldonk
19a7270b2c Add Collection type to builtins list 2025-03-15 21:14:46 +01:00
Ruud van Asseldonk
340add7ce5 Add reminder to preserve type info in Collection
It would be nice to have that, but the current implementation is not
incorrect, so let's do the easy thing for now, we can always make it
better later.
2025-03-15 21:13:43 +01:00
Ruud van Asseldonk
9debc3a7fe Clarify the meaning of TypeDiff cases
At first I wasn't sure if I need to add Collection here, and how to
report an inner mismatch. But now it's clear, the TypeDiff should match
the expected supertype.
2025-03-15 21:13:43 +01:00
Ruud van Asseldonk
8c314435b8 Propagate Collection expectation into literals
It already worked before, but we would only report the mismatch
afterwards, and not blame inside, maybe even insert a runtime check.
Propagating the expecation inside results in better errors and more
efficient code.
2025-03-15 21:13:43 +01:00
Ruud van Asseldonk
9054cb9bf2 Define a Collection supertype for List and Set
I want to add an unpack operator, and to be able to type the type
expectation, I need a collection supertype for List and Set. Maybe
once I have this, I can actually type the union operator in a more
elegant way as well and I no longer need unpack. But unpack seems
nice anyway, and a Collection supertype seems nice as well.
2025-03-15 21:13:43 +01:00
Ruud van Asseldonk
65b371f46a Merge keyword generation script
For a long time, the names of builtins and types were duplicated in
many places, which is annoying to update every time, and it’s easy to
forget one. This happened in one instance: the Vim plugin was missing
the enumerate builtin. This generates most of them from the Pygments
grammar. There is still some duplication, in particular the definitions
in the RCL source. I think that's fine for now. At some point it may
be nice to add an auxiliary binary that outputs all method names, to
automate that part. This also changes the smith fuzzer, in a way that
future changes to builtins should be less disruptive to the fuzz corpus.
2025-03-15 21:08:16 +01:00
Ruud van Asseldonk
a34aec267b Autoformat Python sources, make Mypy happy
The module name and path hack throws off Mypy, in different ways
depending on how you run it (outside Nix shell, inside Nix develop
shell, or as part of the flake check ...). Let's just forward-declare
it and sidestep problems.

Maybe I should make this script the source of truth and generate the
Pygments grammar from it. We could do that later, for now this works.
2025-03-15 20:54:25 +01:00
Ruud van Asseldonk
bdbb82ccf1 Add reminder to integrate generate_keywords on CI
I should do it, and if I don't do it now then I probably will not do it
soon. On the other hand, no need to let the perfect be the enemy of the
good; calling the script manually is already much better than having to
update all the places manually. So let's merge it as it is.
2025-03-15 20:46:00 +01:00
Ruud van Asseldonk
789c89b520 Generate the Vim plugin from builtins
This corrects one bug in the plugin there that went unnoticed: the
'enumerate' builtin was not highlighted previously. So that's a win
for generating things!
2025-03-15 20:43:21 +01:00
Ruud van Asseldonk
994df536df Delete builtins from highlight module
Let's not put too much effort in the highlight command, the fmt command
prints in color and should be preferred anyway.
2025-03-15 19:58:19 +01:00
Ruud van Asseldonk
5bcc7e74c7 Generate builtins list for the smith fuzzer
This moves one more place of duplication of builtins into
generate_keywords.py as a single source of truth, resolving
a to do in the smith fuzzer.

This does once more shuffle all of these around in the fuzzer, which
makes the existing fuzz corpus mostly meaningless. Fortunately, this
should be the last time that this happens: with the new approach we
can modify the builtins with minimal changes to the meaning of the
fuzz corpus, which is something that I wanted for a long time.
2025-03-15 19:43:13 +01:00
Ruud van Asseldonk
34e347a387 Generate fuzz dictionary from Pygments grammar
I regularly add new methods, and it's becoming tedious to have to
remember to update all the places that reference these, so let's
generate them and automate the process. For now, I'm choosing the
Pygments grammar as the source of truth, and the first target to
generate is the fuzz dictionary.
2025-03-03 22:14:27 +01:00
Ruud van Asseldonk
7292a22404 Update Zed extension to latest Tree-sitter grammar 2025-03-02 21:19:41 +01:00
Ruud van Asseldonk
59be133128 Bump version to 0.8.0
I'm leaving the Zed extension pointing to the older commit of the
Tree-sitter grammar, I'll update that after this version bump. It's
a bit awkward to do it this way around, but there are circular
dependencies that can't be avoided. Maybe with an attack on SHA1 it
can be done in theory, but let's not go there.
2025-03-02 21:15:33 +01:00
Ruud van Asseldonk
ab343e935c Finalize changelog for v0.8.0 2025-03-02 20:59:01 +01:00
Ruud van Asseldonk
c8de775eaf Remove unused import from repo sync script 2025-03-02 20:53:12 +01:00
Ruud van Asseldonk
2dbd9ae3d8 Update seed_fuzz_corpus for new fuzzers
Well, "new", they have been there for a while, but apparently I forgot
to update this script.
2025-03-02 20:51:55 +01:00
Ruud van Asseldonk
2abd340013 Link to installation chapter in manual from website 2025-03-02 20:51:55 +01:00
Ruud van Asseldonk
0b99bafd4a Merge addition of the Number.round method 2025-03-02 20:51:25 +01:00
Ruud van Asseldonk
f7814020d9 Handle all exponent cases when rounding decimals
We don't need to overflow when d is very negative, it just rounds to
zero. Identified after staring at the coverage report for a bit and
thinking deeply about it.
2025-03-02 18:32:21 +01:00
Ruud van Asseldonk
b0ed3b5436 Correct bug when rounding doesn't change mantissa
This was discovered by inspecting the coverage report. The branch where
the mantissa didn't need adjustment was not yet covered, and then I
realized that returning the number itself was wrong. It was right in
the past, before I incorporated the exponent, but then I decided that
rounding should get rid of any exponent, and that broke this branch.
This also adds coverage for that branch.
2025-03-02 18:32:21 +01:00
Ruud van Asseldonk
f0e4cd13b5 Add Number.round method
At first I also wanted to support rounding to a negative number of
decimals (so rounding to a positive power of 10), but scope creep,
complications ... I don't need it, and we can always add that later.
2025-03-02 18:32:21 +01:00
Ruud van Asseldonk
4f2f72d6c1 Fix overflow when subtracting decimal exponents
This bug was discovered by the fuzz_source fuzzer. A similar construct
is used for subtracting the number of decimals, but that one is not
affected, because the number of decimals is an u8, it can't be negative,
so d1.decimals - d2.decimals is never greater than d1.decimals.
2025-03-02 17:09:27 +01:00
Ruud van Asseldonk
3327e4fbfb Add repository links to website footer 2025-02-28 20:21:56 +01:00
Ruud van Asseldonk
08fd5c7414 Reorder website sections 2025-02-28 20:17:02 +01:00
Ruud van Asseldonk
b1b32adcbc Make website header responsive
Now that I added this "Playground" link, it doesn't fit on one line any
more on mobile. Maybe it needs a hamburger menu but that also doesn't
make that much sense with so few items. For now, I am very sorry
Codeberg, but probably fewer people click that link than people who want
the GitHub repo. The Codeberg repo is still linked further down.
2025-02-28 20:11:33 +01:00
Ruud van Asseldonk
9fa6aa7b78 Tweak section order in readme and website 2025-02-28 20:02:55 +01:00
Ruud van Asseldonk
283e91d6c4 Add status section on the website 2025-02-27 22:50:33 +01:00
Ruud van Asseldonk
60ce70e1a8 Overhaul the readme and docs index page 2025-02-27 22:29:13 +01:00
Ruud van Asseldonk
a3103a9bb1 Remove the json superset vaporware warnings
RCL is now truly -- for all practical purposes, yeah yeah pedantics
surrogate pairs and a file with 20 GiB of zeros are technically valid
json but let's talk about documents used in the real world -- a json
superset!

Also I think I should try to make the readme and index pages a bit more
attractive to people who discover this. I wrote them from my niche
perspective and I had a lot of background about what I was building, but
probably it needs to be explained more to new users.

Also improve a few other things, e.g. as a quick hack, add a
"Playground" link in the website header to make the feature more
discoverable. We can extract it into a separate page at a later stage.
2025-02-26 19:17:17 +01:00
Ruud van Asseldonk
936f865e43 Delete outdated idea files
These were helpful for initial exploration, but are confusing to have
lying around at this point. For example, they pollute the results when
I was 'git grep'ing for remaining references to Int.

The type system has long since been implemented, there is documentation
and a companion blog posts series about its design and implementation.
The idea directory is still there in the Git history for the future
historians, but it has no place any more in the default branch.
2025-02-26 18:40:57 +01:00
Ruud van Asseldonk
c8eee9048d Merge the Into -> Number overhaul, float support
This is the result of a long journey, the early commits in this chapter
have been rebased quite a few times. On top of that, the direction that
the early commits take (adding Float side by side with Int), I later
changed course on that. So the history of this is long and turbulent.

The diff of this merge commit though, if you ignore changes to the
golden tests, is not that bad. The actual changes to the Rust code are
pretty straightforward. The diff is large mostly due to the rename of
Int to Number which affects a *lot* of golden tests.

I chose to preserve the original history, rather than to break it up
into parts that make more sense in hindsight, partially because I think
there is value in preserving it, and partially because it's already open
for a long time and I don't want to block it any longer.

For context of how the number type came to be, I have a companion blog
post in the pipeline that is also linked from the documentation.
2025-02-26 18:35:45 +01:00
Ruud van Asseldonk
e23d943a64 Resolve to do in Decimal implementation
It doesn't apply, the comment was wrong. If there is an overflow, and
the signs are both positive, then m1 really is the greater one. I think
I didn't realize before that they are both positive? Anyway, nothing to
do to address this then.

I'm thinking if there is a test to add, but the logic was just wrong,
and there is already a test case that covers this control flow path, so
I think we're good.
2025-02-26 18:32:30 +01:00
Ruud van Asseldonk
3da6b90193 Note caveat in decimal parser doc comment 2025-02-25 22:21:39 +01:00
Ruud van Asseldonk
f8dd8fd4a2 Test number representation in pyrcl tests 2025-02-25 22:21:39 +01:00
Ruud van Asseldonk
86c08c0eab Add error help for more type misspellings
If I'm doing it for Int, might as well do it for a few other types that
people might try coming from TypeScript or other languages.
2025-02-25 22:21:39 +01:00
Ruud van Asseldonk
4dc14da41b Restore simpler implementation of check_unop
I made it more complex when there were multiple number types, but now
that those are gone again, the previous phrasing was nicer.
2025-02-25 22:21:39 +01:00
Ruud van Asseldonk
dff11cde02 Fix typo in comment in typechecker 2025-02-25 22:21:39 +01:00
Ruud van Asseldonk
c090a5f156 Remove to do from std.parse_int
At this time I don't plan to use the decimal parser for it. We should
instead add a parse_number function.
2025-02-25 22:21:39 +01:00
Ruud van Asseldonk
ec698dae64 Simplify Decimal::parse_str usage in abstractor 2025-02-25 22:21:39 +01:00
Ruud van Asseldonk
b242eb9491 Guard against overflow when parsing decimals
This resolves a few to dos introduced earlier.
2025-02-25 22:21:39 +01:00
Ruud van Asseldonk
0a377514ab Rename golden tests to better match the type 2025-02-25 21:10:01 +01:00
Ruud van Asseldonk
5da7c6530c Make inexact division error a bit friendlier 2025-02-25 20:59:06 +01:00
Ruud van Asseldonk
eaeb54c424 Simplify and document fuzz_decimal fuzzer 2025-02-25 20:49:40 +01:00
Ruud van Asseldonk
7a36947dfb Clean up and clarify Number docs 2025-02-25 20:38:05 +01:00
Ruud van Asseldonk
9a99c63fc7 Add tests to cover Decimal impl, delete unused code
We can resurrect the normalize function from the Git history when
needed. Or just rewrite it from scratch.
2025-02-24 22:04:00 +01:00
Ruud van Asseldonk
27f91ac012 Remove various final references to Int 2025-02-24 21:08:49 +01:00
Ruud van Asseldonk
91cdb43961 Rename Int to Number in formatter golden tests
Again, the formatter doesn't care about type names, so these tests were
not failing before, but still, to make the tests a good example, and to
not cause confusion with outdated code that doesn't work, let's rename
things there too.

This is mostly a mechanical rename, but because the formatter cares
about length, in one case I had to change the example to make it still
exercise the same case.
2025-02-24 21:02:54 +01:00