Skip to main content

Lint

DotHRB includes a static lint option that reports when a variable, explicitly typed as anything other than 'anytype', is assigned a value of a different type. This helps catch certain type mismatches that the compiler overlooks.

Experimental Component

This component is in an experimental phase. There are currently no guarantees of further development. Continued progress is strictly contingent on significant community interest and feedback.

dothrb run test.prg -lint 1 (1 = warnings, 2 = errors)

this code:

#include "dothrb.ch"

function main()

local var1 as date
local var2 as string
local var3 as string

var1 := date()
var1 := var1 - date()
var2 := 10.10
var3 := myfunc()

outstd(var1 + var2 + var3)

return nil

function myfunc( var1 as numeric, var2 as datetime, var3 as hash )
var1 := "12"
var2 := 0
var3 := .t.

return nil

reports:

L001 Variable 'var1' of type date is assigned to 'var1' of type 'undefined' in function 'main'.
L001 Variable 'var2' of type string is assigned to '10.10' of type 'numeric' in function 'main'.
L001 Variable 'var3' of type string is assigned to 'myfunc()' of type 'undefined' in function 'main'.
L001 Variable 'var1' of type numeric is assigned to '"12"' of type 'string' in function 'myfunc'.
L001 Variable 'var2' of type datetime is assigned to '0' of type 'numeric' in function 'myfunc'.
L001 Variable 'var3' of type hash is assigned to '.t.' of type 'logical' in function 'myfunc'.