Skip to content

Conversation

@kmr-srbh
Copy link
Contributor

@kmr-srbh kmr-srbh commented Feb 28, 2024

Overview

Trying to access a key from a Const dict threw a SemanticError stating type mismatch. An ASR pass error was thrown when trying to access values from a Const list, Const tuple and Const str. This was chiefly because the case of a Const value was not addressed in handling subscript indices.

  • Screenshot from 2024-02-26 12-21-43

  • Screenshot from 2024-02-29 19-25-04

Fix

  • Check for Const when visiting subscript indices and handle item access through the contained type in the llvm back-end.

  • Throw a SemanticError for immutable types like tuple and str.

  • Tuple

Screenshot from 2024-02-29 20-27-55

  • String

Screenshot from 2024-02-29 20-37-10

  • Dictionary

Screenshot from 2024-02-29 20-28-35

  • List

Screenshot from 2024-02-29 20-29-00

Note

The get attribute of Const dict still throws a SemanticError now. I will push the fix for that in a separate PR.

@kmr-srbh
Copy link
Contributor Author

kmr-srbh commented Feb 28, 2024

@certik Please guide me where I should put the tests. It is a bit difficult to understand now. Is this the correct folder? Shall I refactor them to a more professional and readable manner?

… immutable types like `tuple` and `string`.
@kmr-srbh kmr-srbh marked this pull request as ready for review February 29, 2024 15:00
@kmr-srbh
Copy link
Contributor Author

kmr-srbh commented Mar 3, 2024

The failing tests are irrelevant to the changes made.

@kmr-srbh kmr-srbh changed the title Add support for accessing values from Const types. Add support for accessing values from data-structures contained within Const Mar 7, 2024
@Thirumalai-Shaktivel
Copy link
Collaborator

Please mark this PR ready for review once it is ready.

@Thirumalai-Shaktivel Thirumalai-Shaktivel marked this pull request as draft March 7, 2024 06:06
@kmr-srbh kmr-srbh closed this Mar 7, 2024
@kmr-srbh kmr-srbh deleted the fix-const-access branch March 11, 2024 07:50
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.

2 participants