[Bug 1351] New: informative error when using Swift keyword
https://bugzilla.mcs.anl.gov/swift/show_bug.cgi?id=1351 Summary: informative error when using Swift keyword Product: Swift Version: trunk Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Error messages AssignedTo: [email protected] ReportedBy: [email protected] CC: [email protected] Just saw a user defining an app as: app (file out) myapp (file exe, file in){ bash @exe @in stdout=@out; } The error he was facing is: Could not compile SwiftScript source: line 3:24: expecting an identifier, found 'in' Replacing 'in' with '_in' fixed the error. The error message should be more explicit in saying that 'in' is a Swift keyword and can not be used as a variable (if that is the cause of the error, which I think is). Thanks, Ketan -- Configure bugmail: https://bugzilla.mcs.anl.gov/swift/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.mcs.anl.gov/swift/show_bug.cgi?id=1351 --- Comment #1 from Mihael Hategan <[email protected]> 2014-10-19 19:38:28 --- I'm inclined to say that this shouldn't be fixed for two reasons: 1. the message somewhat clearly states that 'in' is not a valid identifier. The documentation should state that keywords cannot be used as an identifier, though this is a pretty universal thing across languages. 2. the effort required in fixing it (messing with ANTLR) seems higher than the gain. For reference, here's what a few other languages do in this case (Ruby is the only one that clarifies what the exact issue is): --------------Python------------- def test(for): pass -> File "./test1.py", line 3 def test(for): ^ SyntaxError: invalid syntax ---------------Ruby-------------- def test(for) end -> ./test1.rb:3: syntax error, unexpected keyword_for, expecting ')' def test(for) ---------------Java-------------- class test1 { public void test(int for) {} } -> test1.java:3: error: <identifier> expected public void test(int for) { ^ test1.java:3: error: ';' expected public void test(int for) { ^ 2 errors ----------------GCC-------------- void test(int for) {} void main(void) {} -> test1.c:1:15: error: expected ';', ',' or ')' before 'for' void test(int for) { ^ -- Configure bugmail: https://bugzilla.mcs.anl.gov/swift/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.mcs.anl.gov/swift/show_bug.cgi?id=1351 Mihael Hategan <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WONTFIX -- Configure bugmail: https://bugzilla.mcs.anl.gov/swift/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
participants (1)
-
bugzilla-daemon@mcs.anl.gov