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

CU-86drpndnn - Throw a compilation error when variable type declaration doesn't match the assigned value type #1242

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

luc10921
Copy link
Contributor

Summary or solution description
When assigning a variable and defining the type of said as a constant (like a number or hardcoded string) of a different type, it should throw an error.

Platform:

  • OS: Windows 10 x64
  • Python version: Python 3.11

@luc10921 luc10921 requested a review from meevee98 April 23, 2024 19:07
@luc10921 luc10921 self-assigned this Apr 23, 2024
@melanke
Copy link
Contributor

melanke commented Apr 23, 2024

# TODO: check if the annotated type and the value type are the same #86a1ctmwy
if isinstance(ann_assign.value, ast.Constant):
annotation_type = self.get_type(ann_assign.value)
if var_type is not annotation_type:

Choose a reason for hiding this comment

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

The variable var_type is not defined before it's used. Please ensure that var_type is defined and assigned the correct value before this line.

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 91.909% (+0.002%) from 91.907%
when pulling acb3f52 on CU-86drpndnn
into 10b77de on development.

@meevee98 meevee98 merged commit d2afffe into development Apr 23, 2024
4 checks passed
@meevee98 meevee98 deleted the CU-86drpndnn branch April 23, 2024 22:00
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.

4 participants