Skip to content

Fix issue #568 (no error for file self reference) - #748

Merged
Mohamed Hegazy (mhegazy) merged 11 commits into
microsoft:masterfrom
chrisbubernak:selfReferencingFileError
Oct 1, 2014
Merged

Mohamed Hegazy (mhegazy) merged 11 commits into
microsoft:masterfrom
chrisbubernak:selfReferencingFileError

Conversation

@chrisbubernak

Copy link
Copy Markdown
Contributor

Fix issue #568 where no error is being displayed when a file tries to reference itself.

The compiler now shows the error message "A file cannot have a reference to itself." when a file tries to reference itself. I've included 3 unit tests for this fix. The first has a file that tries to reference itself and should fail with this error. The second tries to reference a file of the same name but a different base path and, while it won't fail with the same file reference error, it should fail with a file not found error. The third test is a permutation of the first and references the same file but with "./" appended to the front, after normalizing the file paths this should fail as it is a reference to the same file.

Comment thread src/compiler/parser.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what about different casing? use getCanonicalFileName to ensure you are getting a consistent name for the file depending on the underlying host's case sensitivity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

can I just use toLocaleLowerCase() for each filename in the comparison? It looks like inside this function I don't have a reference to host so I can't call getCanonicalFileName and because we don't actually care what the casing is inside the comparison (just that they are using the same casing) getCanonicalFileName seems unnecessary.

@mhegazy

Copy link
Copy Markdown
Contributor

Thanks Chris Bubernak (@chrisbubernak). I had a few comments on the change, also we will need you to submit a Contributor License Agreement (CLA) before accepting this pull request. Download the agreement (Microsoft Contribution License Agreement.docx), sign, scan, and email it back to [email protected].

For more information please check out CONTRIBUTING.md

@chrisbubernak

Copy link
Copy Markdown
Contributor Author

I'm actually a Microsoft employee and I sent mail to your team yesterday about this and it sounded like I could contribute without the agreement, if that's not the case just let me know and I'll get that filled out.

@danquirk

Copy link
Copy Markdown
Member

Need to fix the failing tests

@mhegazy

Copy link
Copy Markdown
Contributor

thanks Chris Bubernak (@chrisbubernak), my bad. did not connect the two threads :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use a number greater than the last number in the 1xxx range. We dn't want to reuse error numbers used by the V1 compiler. Thanks!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

old compiler had this as error code 5006, can we keep the same error code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I originally had it as a 5006 error but I was told to change it to put it in the 1000 range.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1000 is fine. we have moved these around lately. so I would keep them all consistent. thanks.

@mhegazy

Copy link
Copy Markdown
Contributor

thanks. LGTM.
👍

@mhegazy

Copy link
Copy Markdown
Contributor

Sheetal Nandi (@sheetalkamat) any other comments?

@mhegazy

Copy link
Copy Markdown
Contributor

thanks.

Mohamed Hegazy (mhegazy) added a commit that referenced this pull request Oct 1, 2014
Fix issue #568 (no error for file self reference)
@mhegazy
Mohamed Hegazy (mhegazy) merged commit a37106d into microsoft:master Oct 1, 2014
@chrisbubernak
Chris Bubernak (chrisbubernak) deleted the selfReferencingFileError branch October 4, 2014 17:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants