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

[program-gen] Fix generation of double literals in generated programs #1580

Merged
merged 9 commits into from
Jan 9, 2025

Conversation

Zaid-Ajaj
Copy link
Contributor

@Zaid-Ajaj Zaid-Ajaj commented Jan 8, 2025

Description

This PR implements an initial pass for handling __convert calls in program-gen starting with double literals. Later on we will extend this to handle enums but we don't have a conformance test for these yet.

The return type of __convert calls is annotated with the target schema type so we detect when are going to emit an expression of type model.NumberType (in PCL space) in a location that expects schema.NumberType. When that pattern is detected we make sure to emit double literals that end with .0 when the value of the number is exact.

@Zaid-Ajaj Zaid-Ajaj requested a review from a team as a code owner January 8, 2025 16:25
@Zaid-Ajaj
Copy link
Contributor Author

Zaid-Ajaj commented Jan 8, 2025

It looks like the program generation tests (not conformance tests) are failing due to missing type information of object expressions. I'll have a look

EDIT: tests should be fixed now ✅

@Zaid-Ajaj Zaid-Ajaj merged commit 70c572a into main Jan 9, 2025
23 checks passed
@Zaid-Ajaj Zaid-Ajaj deleted the zaid/double-instrinsics branch January 9, 2025 14:32
Zaid-Ajaj added a commit that referenced this pull request Jan 9, 2025
### Description

Fixes how we are generating map and array literals when they are
_untyped_. The problem was that we generated just the elements i.e. `[1,
2, 3]` in PCL would generate `1, 2, 3` in java because Array-typed
resource inputs accepts the elements being spread like that i.e.
`resourceInputs = [1,2,3]` (PCL) generated `resourceInputs(1, 2, 3)`
(Java). However this doesn't work when we are initializing lists and
maps outside of resource inputs: local variables and output variables.

This PR addresses the problem by using `Map.ofEntries(...)` and
`List.of(...)` when applicable.

Branch is written on top of #1580

- Fixes #1561 
- Fixes #1560 
- Unskips `l1-output-map`
- Unskips `l1-output-array`
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.

[programgen] Better generation of numeric literals
2 participants