-
Notifications
You must be signed in to change notification settings - Fork 31
Fix an error when specify --define=foo
#527
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
Conversation
…dling `@options.define` is expect to Array so default value is also Array not Hash.
|
I'm not sure why steep didn't warn however please update type declaration too. Line 4 in 7fa74d8
|
|
[Note] It seems steep 1.9.3 doesn't warn on array assignment to Hash type instance variable: # code
@define = []
# rbs
attr_accessor define: Hash[String, String]$ bundle exec steep check
# Type checking files:
......................................................................................................................
No type error detected. 🫖but it warns on hash assignment to Array type instance variable: # code
@define = {}
# rbs
attr_accessor define: Array[String]$ bundle exec steep check
# Type checking files:
.....................................................................F................................................
lib/lrama/options.rb:15:16: [warning] Empty hash doesn't have type annotation
│ Diagnostic ID: Ruby::UnannotatedEmptyCollection
│
└ @define = {}
~~
Detected 1 problem from 1 file |
|
This change alone is probably not sufficient, and changes are needed, for example, in the location of the assignment at below. Line 28 in 7fa74d8
By the way, I think Hash is appropriate for define because it is written in the grammar file as %define lr.type ielr or from the command line as lrama -D lr.type=ielr, but why change it to Array?
|
Changes there will be made separately. Certainly as it is now, if a value is missing, it will result in an error.
I didn't mean to change the Line 60 in 7fa74d8
This PR simply changes the default value from Hash to Array. lrama/lib/lrama/option_parser.rb Line 63 in 968725e
If I understand something incorrectly, please point it out to me. |
``` ❯ exe/lrama --define=foo sample/calc.y wrong array length at 0 (expected 2, was 1) ``` This is occurring and has been addressed below: https://github.com/ruby/lrama/blob/7fa74d84a68b3632950b969d29ccf012a0ea4a42/lib/lrama/grammar.rb#L60
--define=foo
I see, indeed. My understanding was wrong. |
This is occurring and has been addressed below:
lrama/lib/lrama/grammar.rb
Line 60 in 7fa74d8