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

feat: slice, rawSlice, ascii and crc32 built-in functions #787

Merged
merged 19 commits into from
Sep 5, 2024

Conversation

Gusarich
Copy link
Member

@Gusarich Gusarich commented Sep 3, 2024

Issue

Closes #444.

  • slice() isn't actually an equivalent of any string literals, but just a more efficient way to define slice constants from BOC, similarly to cell()
  • rawSlice("abcd") is an equivalent of "abcd"s in FunC
  • ascii("hello world") is an equivalent of "hello world"u in FunC
  • crc32("hello world") is an equivalent of "hello world"c in FunC

Checklist

  • I have updated CHANGELOG.md
  • I have documented my contribution in Tact Docs: https://github.com/tact-lang/tact-docs/pull/PR-NUMBER
  • I have added tests to demonstrate the contribution is correctly implemented: this usually includes both positive and negative tests, showing the happy path(s) and featuring intentionally broken cases
  • I have run all the tests locally and no test failure was reported
  • I have run the linter, formatter and spellchecker
  • I did not do unrelated and/or undiscussed refactorings

@Gusarich Gusarich requested review from anton-trunov and a team and removed request for anton-trunov September 3, 2024 06:01
@Gusarich Gusarich changed the title String functions feat: slice, rawSlice, ascii and crc32 built-in functions Sep 3, 2024
@anton-trunov anton-trunov added this to the v1.5.0 milestone Sep 3, 2024
@anton-trunov anton-trunov self-assigned this Sep 3, 2024
Copy link
Member

@anton-trunov anton-trunov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. What does slice and rawSlice correspond to in FunC string suffixes?
  2. Let's add some negative tests, for instance, ascii("000000000000000000000000000000000") is supposed to fail due to overflow (33 zeros * 8 = 264 bits)`

@anton-trunov
Copy link
Member

cspell

@Gusarich
Copy link
Member Author

Gusarich commented Sep 4, 2024

fixed

Copy link
Member

@anton-trunov anton-trunov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a negative test with rawSlice(s) where s won't fit into a cell

src/interpreter.ts Outdated Show resolved Hide resolved
Copy link
Member

@anton-trunov anton-trunov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

@anton-trunov anton-trunov merged commit dc70c18 into tact-lang:main Sep 5, 2024
3 checks passed
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

Successfully merging this pull request may close these issues.

Introduce comptime builtins corresponding to FunC string literal types
2 participants