[ragel-users] "declared but not used" errors with v7 Go backend

Adrian Thurston thurston at colm.net
Sun Nov 25 08:18:11 UTC 2018


 

Just added the assignment to _ to master. 

Thank you for the fix. 

Still having problems building master? 

On 2018-11-01 10:12, Damian Gryski wrote: 

> This is with ragel 7.0.0.11 and colm 0.13.0.6. I was unable to get ragel to build from git. 
> 
> With the example grammar at github.com/dgryski/ragel-examples/regexp1 [2], I get the following error: 
> 
> $ ragel-go sshd.rl 
> $ go build 
> # github.com/dgryski/ragel-examples/regexp1 [2] 
> ./sshd.go:11:6: _scanner_trans_cond_spaces declared and not used 
> ./sshd.go:12:6: _scanner_trans_offsets declared and not used 
> ./sshd.go:13:6: _scanner_trans_lengths declared and not used 
> ./sshd.go:14:6: _scanner_cond_keys declared and not used 
> ./sshd.go:17:6: _scanner_eof_cond_spaces declared and not used 
> ./sshd.go:18:6: _scanner_eof_cond_key_offs declared and not used 
> ./sshd.go:19:6: _scanner_eof_cond_key_lens declared and not used 
> ./sshd.go:20:6: _scanner_eof_cond_keys declared and not used 
> ./sshd.go:21:6: _scanner_nfa_targs declared and not used 
> ./sshd.go:22:6: _scanner_nfa_offsets declared and not used 
> ./sshd.go:22:6: too many errors 
> 
> The usual solution to this in autogenerated code is to assign them to `_`, the underscore "blank variable". This satisfies the compiler and the entire array will be eliminated as a dead-store if it ends up not being used. 
> 
> Thus, each declaration for variables which may or may not be used will look like: 
> var _scanner_trans_cond_spaces [] int8 = [] int8 { ... } 
> _ = _scanner_trans_cond_space 
> 
> Note also the first `[] int8` is redundant -- the compiler will infer the type from the type of the array on the right hand side of the `=`. 
> 
> Fixing these issues in the Go template in the src/host-go directory and rebuilding fixed these errors (although I had to copy files from the git checkout for the template changes to recompile successfully). 
> 
> Damian 
> 
> _______________________________________________
> ragel-users mailing list
> ragel-users at colm.net
> http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users [1]
 

Links:
------
[1] http://www.colm.net/cgi-bin/mailman/listinfo/ragel-users
[2] http://github.com/dgryski/ragel-examples/regexp1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20181125/115623a6/attachment.html>


More information about the ragel-users mailing list