feat: enforce maximum method name length of 64 characters in compiler
Add MAX_METHOD_NAME constant and validation in copyName() to prevent method names exceeding 64 characters. When a method name is too long, the compiler now reports an error and truncates the name to the maximum allowed length. Also update MAX_METHOD_SIGNATURE to be derived from MAX_METHOD_NAME and MAX_PARAMETERS. Add test cases for valid 64-character method names, names that exceed the limit, and a call to an overlong method name.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// Unicode characters are allowed in comments.
|
||||
//
|
||||
// Latin 1 Supplement: £§¶ÜÞ
|
||||
// Latin Extended-A: ĐĦŋœ
|
||||
// Latin Extended-B: ƂƢƩǁ
|
||||
// Other stuff: ឃᢆ᯽₪ℜ↩⊗┺░
|
||||
// Emoji: ☃☺♣
|
||||
|
||||
// TODO(bob): What about combining characters?
|
||||
|
||||
io.write("ok") // expect: ok
|
||||
@@ -0,0 +1,4 @@
|
||||
// Don't want to actually execute it.
|
||||
if (false) {
|
||||
0.thisIsAMethodNameThatExceedsTheMaximumNameLengthOf64CharactersBy1 // expect error
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum {
|
||||
return "result"
|
||||
}
|
||||
}
|
||||
|
||||
io.write(Foo.new.thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
thisIsAMethodNameThatExceedsTheMaximumNameLengthOf64CharactersBy1 { // expect error
|
||||
"body"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user