AttributeError: 'NoneType' object has no attribute 'pos'
Zekao opened this issue · 5 comments
Describe the bug
File "/opt/homebrew/bin/norminette", line 8, in <module>
sys.exit(main())
^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/norminette/__main__.py", line 155, in main
registry.run(context, source)
File "/opt/homebrew/lib/python3.11/site-packages/norminette/registry.py", line 61, in run
ret, jump = self.run_rules(context, rule)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/norminette/registry.py", line 37, in run_rules
self.run_rules(context, rule)
File "/opt/homebrew/lib/python3.11/site-packages/norminette/registry.py", line 29, in run_rules
result = rule.run(context)
^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/norminette/rules/check_func_declaration.py", line 68, in run
context.new_error("TOO_MANY_ARGS", context.peek_token(i))
File "/opt/homebrew/lib/python3.11/site-packages/norminette/context.py", line 249, in new_error
pos = tkn.pos
^^^^^^^
AttributeError: 'NoneType' object has no attribute 'pos'
Erroneous code
int main (void)
{
int array[] = {1, 2, 3, 4, 5};
return (0);
}
Additional infos
- OS: Darwin 23.1.0 arm64
- python3 --version: Python 3.11.6
- norminette -v: norminette 3.3.55
I have applied the fix but I get the same error reported, with just some slight difference in the line number
File "/Users/merlot/Library/Python/3.8/lib/python/site-packages/norminette/context.py", line 247, in new_error pos = tkn.pos AttributeError: 'NoneType' object has no attribute 'pos'
Hey, @merlot-dev, can you provide the full traceback error or the code that you used?
Of course
Traceback (most recent call last):
File "/Users/merlot/Library/Python/3.8/bin/norminette", line 8, in
sys.exit(main())
File "/Users/merlot/Library/Python/3.8/lib/python/site-packages/norminette/main.py", line 132, in main
registry.run(context)
File "/Users/jlgarcia/Library/Python/3.8/lib/python/site-packages/norminette/registry.py", line 54, in run
ret, jump = self.run_rules(context, rule)
File "/Users/merlot/Library/Python/3.8/lib/python/site-packages/norminette/registry.py", line 30, in run_rules
self.run_rules(context, rule)
File "/Users/merlot/Library/Python/3.8/lib/python/site-packages/norminette/registry.py", line 22, in run_rules
result = rule.run(context)
File "/Users/merlot/Library/Python/3.8/lib/python/site-packages/norminette/rules/check_nest_line_indent.py", line 97, in run
self.find_nest_content(context, nest, i)
File "/Users/merlot/Library/Python/3.8/lib/python/site-packages/norminette/rules/check_nest_line_indent.py", line 72, in find_nest_content
context.new_error("TOO_FEW_TAB", context.peek_token(i))
File "/Users/merlot/Library/Python/3.8/lib/python/site-packages/norminette/context.py", line 247, in new_error
pos = tkn.pos
AttributeError: 'NoneType' object has no attribute 'pos'
Hey, @merlot-dev, can you send the code that are you using or a similar snippet? I tried here, but I couldn't get one code that replicates the error
After a git pull at the 42 Campus computer, I haven't got any error there. But I've been solving the norm errors. Then I have git pulled in my macbook (where I got the shown error) and no errors so far. I'll report if it happens again. Thank you anyway