inference and typecheck adapted for pointer types